A colleague spotted an odd thing that neither of us can figure out:
iex(1)> Timex.timezone(“America/Chicago”, {2015,4,12})
#<TimezoneInfo(America/Chicago - CDT (-05:00:00))>
iex(2)> Timex.timezone(“America/Chicago”, {2015,1,12})
#<TimezoneInfo(America/Chicago - CST (-06:00:00))>
I would have expected all calls to timezone in Chicago to be -06:00:00. Is the difference due to Daylight Savings Time or something else?
jerdew
January 20, 2022, 3:39pm
2
DST is probably the cause, but it could possibly be weirder things … timezones are strange. you can set the timezone to a variable, and then examine its properties to see its local offset (offset_std) and when that offset is valid from/until:
iex> tz = Timex.timezone("America/Chicago", {2015,4,12})
iex> tz.offset_std
3600
iex> z = Timex.timezone("America/Chicago", {2015,1,12})
iex> tz.offset_std
0
iex> tz.from
{:sunday, {{2014, 11, 2}, {1, 0, 0}}}
iex> tz.until
{:sunday, {{2015, 3, 8}, {2, 0, 0}}}
1 Like
Yeah that sure looks like it’s Daylight Savings Time. Thanks for the reply @jerdew !