[tz] Welcome to the "tz" mailing list
Brian Inglis
Brian.Inglis at SystematicSw.ab.ca
Wed May 20 15:17:29 UTC 2020
On 2020-05-20 05:32, Sundar Sarma wrote:
> According to the latest 2020a tz update: Canada's Yukon, represented by
> America/Whitehorse and
> America/Dawson, advanced to -07 year-round, beginning with its
> spring-forward transition on 2020-03-08, and will not fall back on
> 2020-11-01.
> We have written a test cases like below for canada yukon timezone. We imported
> new 2020a tz into our environment.
> Our code seems correct but test cases are failing. So we found that there is
> wrong in Iana tz side.
> Please check and correct us. This is the below code we have written.
> @Test
> public void doesNotFallBackToMinus8InDawsonNovember2020() {
> DateTimeZone timezone = DateTimeZone.forID("America/Dawson");
> Instant dayAfter = new DateTime(2020, 11, 2, 0, 0, timezone)-------> on
> 2nd nov 00:00:00
> .withLaterOffsetAtOverlap()
> .toInstant();
> Instant day = new DateTime(2020, 11, 1, 0, 0, timezone)------> on 1 st
> nov 00:00:00
> .withLaterOffsetAtOverlap()
> .toInstant();
> long dayAfterOffset = timezone.getOffset(dayAfter.getMillis());
> int dayAfterHours = (int) TimeUnit.MILLISECONDS.toHours(dayAfterOffset);
> long offsetOnDay = timezone.getOffset(day.getMillis());
> int hoursOnDay = (int) TimeUnit.MILLISECONDS.toHours(offsetOnDay);
> assertEquals(hoursOnDay, dayAfterHours); -------> here we are getting
> error: java.lang.AssertionError: expected:<-7> but was:<-8>
> }
> The above test case according to your update (will not fall back on 2020-11-01)
> is correct. But test case is failing.
> Could you please clarify us that is there anything wrong from IANA tz.
> If not how can i write my test case according to that?
For a start, you must always take account of the summer transition times forward
and back.
Across Canada, times change at Sunday 02:00 local time: in March, as each time
zone hits 02:00, it becomes 03:00; in November, as each time zone hits 02:00, it
becomes 01:00:
$ zdump -Vc2020,2021 Canada/Mountain | sed 's/\(Sun\).*\1/\1/'
Canada/Mountain Sun Mar 8 01:59:59 2020 MST isdst=0 gmtoff=-25200
Canada/Mountain Sun Mar 8 03:00:00 2020 MDT isdst=1 gmtoff=-21600
Canada/Mountain Sun Nov 1 01:59:59 2020 MDT isdst=1 gmtoff=-21600
Canada/Mountain Sun Nov 1 01:00:00 2020 MST isdst=0 gmtoff=-25200
so to be sure, you need to check on or after each transition, as you will have
ambiguous times on Sunday in March between 01:00 and 02:00, and in November
between 02:00 and 03:00.
In both cases, you could check on or after Sun 03:00.
Checking at 12:00 noon is often chosen to be safe regardless of actual
transition times, which could vary from 00:00 to 06:00.
Similarly, checks are often done on December 31 and June 30 to avoid being near
any northern or southern hemisphere transition dates.
However in recent years Islamic countries have started to reset summer time
changes during Ramadan, which can occur any time in the Gregorian calendar.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in IEC units and prefixes, physical quantities in SI.]
More information about the tz
mailing list