Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8324065

Daylight saving information for `Africa/Casablanca` are incorrect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 23
    • None
    • core-libs
    • None
    • b07
    • generic
    • generic

    Description

      The definition of the `Africa/Casablanca` zone has `1:00` as the standard offset since 10/28/2018, and the rules for the zone has entries beyond the year 2037, such as:

      ```
      Rule Morocco 2037 only - Oct 4 3:00 -1:00 -
      Rule Morocco 2037 only - Nov 15 2:00 0 -
      Rule Morocco 2038 only - Sep 26 3:00 -1:00 -
      Rule Morocco 2038 only - Oct 31 2:00 0 -
      Rule Morocco 2039 only - Sep 18 3:00 -1:00 -
      Rule Morocco 2039 only - Oct 23 2:00 0 -
      ...
      Rule Morocco 2086 only - Apr 14 3:00 -1:00 - (*)
      Rule Morocco 2086 only - May 19 2:00 0 -
      Rule Morocco 2087 only - Mar 30 3:00 -1:00 -
      Rule Morocco 2087 only - May 11 2:00 0 -
      ```

      So for example, looking at the transition marked with `*`, the following code

      ```
              var tz = TimeZone.getTimeZone("Africa/Casablanca");
              var zi = tz.toZoneId();

              var i = ZonedDateTime.of(LocalDateTime.of(2086, 4, 14, 2, 59), zi).toInstant();
              var d = Date.from(i);
              System.out.println(zi.getRules().isDaylightSavings(i));
              System.out.println(tz.inDaylightTime(d));
              i = ZonedDateTime.of(LocalDateTime.of(2086, 4, 14, 3, 0), zi).toInstant();
              d = Date.from(i);
              System.out.println(zi.getRules().isDaylightSavings(i));
              System.out.println(tz.inDaylightTime(d));
      ```
      should print:
      ```
      true
      true
      false
      false
      ```
      but current implementation prints:
      ```
      true
      true
      false
      true
      ```
      The cause of this issue was there is the definition of the `last year` as `2037`, and transitions are only considered till that year. This restriction seems to come from the old `zic` implementation, thus no longer applicable to the JDK. The `last year` has to be expanded to some year after 2087, which is the greatest transition year currently existing in the TZDB files.

      Attachments

        Issue Links

          Activity

            People

              naoto Naoto Sato
              naoto Naoto Sato
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: