I’m working on an application that hosts videos, and each video has an upload date and time (stored in UTC). I’d like to format this date and time according to the user’s timezone. For this, I use the elm/time package with
Time.here to get the user zone and
Time.toHours to display the hour corresponding to an upload time.
Last week we had a DST change, and as a result
Time.here is not giving the same zone offset and all displayed dates have been shifted by 1h. I want to display the time from the timezone where the user was
at that moment. How can I do that? For example, in JS, if you ask the timezone offset of dates, in France, you get this:
> new Date("2020-10-15T19:00:00.000Z").getTimezoneOffset() -120 > new Date("2020-10-27T20:00:00.000Z").getTimezoneOffset() -60
In France, both represent 21:00, but using
Time.toHours with the zone returned by
Time.here displays 20 for the first one, and 21 for the second, as you can see in this ellie. How would you go about displaying 21 for both in Elm?