Skip to content

Commit e15abf3

Browse files
committed
8324065: Daylight saving information for Africa/Casablanca are incorrect
Backport-of: 0d8543d6773a516dad54038070dce507179d0709
1 parent de20242 commit e15abf3

File tree

6 files changed

+37
-39
lines changed

6 files changed

+37
-39
lines changed

src/java.base/share/classes/sun/util/calendar/ZoneInfo.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -45,14 +45,14 @@
4545
* for the {@link #getOffset(int,int,int,int,int,int) getOffset}
4646
* method that takes Gregorian calendar date fields.
4747
* <p>
48-
* This table covers transitions from 1900 until 2037 (as of version
49-
* 1.4), Before 1900, it assumes that there was no daylight saving
48+
* This table covers transitions from 1900 until 2100 (as of version
49+
* 23), Before 1900, it assumes that there was no daylight saving
5050
* time and the <code>getOffset</code> methods always return the
5151
* {@link #getRawOffset} value. No Local Mean Time is supported. If a
5252
* specified date is beyond the transition table and this time zone is
53-
* supposed to observe daylight saving time in 2037, it delegates
53+
* supposed to observe daylight saving time in 2100, it delegates
5454
* operations to a {@link java.util.SimpleTimeZone SimpleTimeZone}
55-
* object created using the daylight saving time schedule as of 2037.
55+
* object created using the daylight saving time schedule as of 2100.
5656
* <p>
5757
* The date items, transitions, GMT offset(s), etc. are read from a database
5858
* file. See {@link ZoneInfoFile} for details.

src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -398,16 +398,16 @@ static long readEpochSec(DataInput in) throws IOException {
398398
// ZoneInfo starts with UTC1900
399399
private static final long UTC1900 = -2208988800L;
400400

401-
// ZoneInfo ends with UTC2037
402-
// LocalDateTime.of(2038, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1;
403-
private static final long UTC2037 = 2145916799L;
401+
// ZoneInfo ends with UTC2100
402+
// LocalDateTime.of(2101, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1;
403+
private static final long UTC2100 = 4133980799L;
404404

405-
// ZoneInfo has an ending entry for 2037, this need to be offset by
405+
// ZoneInfo has an ending entry for 2100, this need to be offset by
406406
// a "rawOffset"
407-
// LocalDateTime.of(2037, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC));
408-
private static final long LDT2037 = 2114380800L;
407+
// LocalDateTime.of(2100, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC);
408+
private static final long LDT2100 = 4102444800L;
409409

410-
//Current time. Used to determine future GMToffset transitions
410+
//Current time. Used to determine future GMT offset transitions
411411
private static final long CURRT = System.currentTimeMillis()/1000;
412412

413413
/* Get a ZoneInfo instance.
@@ -474,7 +474,7 @@ private static ZoneInfo getZoneInfo(String zoneId,
474474

475475
for (; i < savingsInstantTransitions.length; i++) {
476476
long trans = savingsInstantTransitions[i];
477-
if (trans > UTC2037) {
477+
if (trans > UTC2100) {
478478
// no trans beyond LASTYEAR
479479
lastyear = LASTYEAR;
480480
break;
@@ -621,11 +621,11 @@ private static ZoneInfo getZoneInfo(String zoneId,
621621
}
622622
} else if (nTrans > 0) { // only do this if there is something in table already
623623
if (lastyear < LASTYEAR) {
624-
// ZoneInfo has an ending entry for 2037
624+
// ZoneInfo has an ending entry for 2100
625625
//long trans = OffsetDateTime.of(LASTYEAR, 1, 1, 0, 0, 0, 0,
626626
// ZoneOffset.ofTotalSeconds(rawOffset/1000))
627627
// .toEpochSecond();
628-
long trans = LDT2037 - rawOffset/1000;
628+
long trans = LDT2100 - rawOffset/1000;
629629

630630
int offsetIndex = indexOf(offsets, 0, nOffsets, rawOffset/1000);
631631
if (offsetIndex == nOffsets)
@@ -810,7 +810,9 @@ private static int getYear(long epochSecond, int offset) {
810810
private static final long DST_MASK = 0xf0L;
811811
private static final int DST_NSHIFT = 4;
812812
private static final int TRANSITION_NSHIFT = 12;
813-
private static final int LASTYEAR = 2037;
813+
// The `last` year that transitions are accounted for. If there are
814+
// rules that go beyond this LASTYEAR, the value needs to be expanded.
815+
private static final int LASTYEAR = 2100;
814816

815817
// from: 0 for offset lookup, 1 for dstsvings lookup
816818
private static int indexOf(int[] offsets, int from, int nOffsets, int offset) {

test/jdk/java/util/TimeZone/NegativeDSTTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
3737

3838
/**
3939
* @test
40-
* @bug 8212970
40+
* @bug 8212970 8324065
4141
* @summary Test whether the savings are positive in time zones that have
4242
* negative savings in the source TZ files.
4343
* @run testng NegativeDSTTest
@@ -81,7 +81,10 @@ private Object[][] negativeDST () {
8181
{CASABLANCA, LocalDate.of(2019, 5, 6), 0, false},
8282
{CASABLANCA, LocalDate.of(2037, 10, 5), 0, false},
8383
{CASABLANCA, LocalDate.of(2037, 11, 16), ONE_HOUR, true},
84+
{CASABLANCA, LocalDate.of(2038, 9, 27), 0, false},
8485
{CASABLANCA, LocalDate.of(2038, 11, 1), ONE_HOUR, true},
86+
{CASABLANCA, LocalDate.of(2087, 3, 31), 0, false},
87+
{CASABLANCA, LocalDate.of(2087, 5, 12), ONE_HOUR, true},
8588
};
8689
}
8790

test/jdk/sun/util/calendar/zi/TestZoneInfo310.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 8007572 8008161 8157792 8212970 8224560
26+
* @bug 8007572 8008161 8157792 8212970 8224560 8324065
2727
* @summary Test whether the TimeZone generated from JSR310 tzdb is the same
2828
* as the one from the tz data from javazic
2929
* @modules java.base/sun.util.calendar:+open
@@ -173,9 +173,9 @@ public static void main(String[] args) throws Throwable {
173173
ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid));
174174
ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid);
175175
/*
176-
* Temporary ignoring the failing TimeZones which are having zone
177-
* rules defined till year 2037 and/or above and have negative DST
178-
* save time in IANA tzdata. This bug is tracked via JDK-8223388.
176+
* Ignoring the failing TimeZones which have negative DST
177+
* save time in IANA tzdata, as javazic/ZoneInfoOld cannot
178+
* handle the negative DST.
179179
*
180180
* These are the zones/rules that employ negative DST in vanguard
181181
* format (as of 2019a), Palestine added in 2022d:
@@ -185,11 +185,6 @@ public static void main(String[] args) throws Throwable {
185185
* - Rule "Namibia"
186186
* - Rule "Palestine"
187187
* - Zone "Europe/Prague"
188-
*
189-
* Tehran/Iran rule has rules beyond 2037, in which javazic assumes
190-
* to be the last year. Thus javazic's rule is based on year 2037
191-
* (Mar 20th/Sep 20th are the cutover dates), while the real rule
192-
* has year 2087 where Mar 21st/Sep 21st are the cutover dates.
193188
*/
194189
if (zid.equals("Africa/Casablanca") || // uses "Morocco" rule
195190
zid.equals("Africa/El_Aaiun") || // uses "Morocco" rule
@@ -198,10 +193,8 @@ public static void main(String[] args) throws Throwable {
198193
zid.equals("Europe/Bratislava") || // link to "Europe/Prague"
199194
zid.equals("Europe/Dublin") || // uses "Eire" rule
200195
zid.equals("Europe/Prague") ||
201-
zid.equals("Asia/Tehran") || // last rule mismatch
202196
zid.equals("Asia/Gaza") || // uses "Palestine" rule
203-
zid.equals("Asia/Hebron") || // uses "Palestine" rule
204-
zid.equals("Iran")) { // last rule mismatch
197+
zid.equals("Asia/Hebron")) { // uses "Palestine" rule
205198
continue;
206199
}
207200
if (! zi.equalsTo(ziOLD)) {

test/jdk/sun/util/calendar/zi/ZoneInfoOld.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -51,14 +51,14 @@
5151
* for the {@link #getOffset(int,int,int,int,int,int) getOffset}
5252
* method that takes Gregorian calendar date fields.
5353
* <p>
54-
* This table covers transitions from 1900 until 2037 (as of version
55-
* 1.4), Before 1900, it assumes that there was no daylight saving
54+
* This table covers transitions from 1900 until 2100 (as of version
55+
* 23), Before 1900, it assumes that there was no daylight saving
5656
* time and the <code>getOffset</code> methods always return the
5757
* {@link #getRawOffset} value. No Local Mean Time is supported. If a
5858
* specified date is beyond the transition table and this time zone is
59-
* supposed to observe daylight saving time in 2037, it delegates
59+
* supposed to observe daylight saving time in 2100, it delegates
6060
* operations to a {@link java.util.SimpleTimeZone SimpleTimeZone}
61-
* object created using the daylight saving time schedule as of 2037.
61+
* object created using the daylight saving time schedule as of 2100.
6262
* <p>
6363
* The date items, transitions, GMT offset(s), etc. are read from a database
6464
* file. See {@link ZoneInfoFile} for details.

test/jdk/sun/util/calendar/zi/Zoneinfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
3737
class Zoneinfo {
3838

3939
private static final int minYear = 1900;
40-
private static final int maxYear = 2037;
40+
private static final int maxYear = 2100;
4141
private static final long minTime = Time.getLocalTime(minYear, Month.JANUARY, 1, 0);
4242
private static int startYear = minYear;
4343
private static int endYear = maxYear;

0 commit comments

Comments
 (0)