8324065: Daylight saving information for Africa/Casablanca are incorrect

Reviewed-by: iris, joehw, jlu
This commit is contained in:
Naoto Sato 2024-01-22 17:15:53 +00:00
parent c9cacfb25d
commit 0d8543d677
6 changed files with 37 additions and 39 deletions

View file

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

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -406,16 +406,16 @@ public final class ZoneInfoFile {
// ZoneInfo starts with UTC1900
private static final long UTC1900 = -2208988800L;
// ZoneInfo ends with UTC2037
// LocalDateTime.of(2038, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1;
private static final long UTC2037 = 2145916799L;
// ZoneInfo ends with UTC2100
// LocalDateTime.of(2101, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC) - 1;
private static final long UTC2100 = 4133980799L;
// ZoneInfo has an ending entry for 2037, this need to be offset by
// ZoneInfo has an ending entry for 2100, this need to be offset by
// a "rawOffset"
// LocalDateTime.of(2037, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC));
private static final long LDT2037 = 2114380800L;
// LocalDateTime.of(2100, 1, 1, 0, 0, 0).toEpochSecond(ZoneOffset.UTC);
private static final long LDT2100 = 4102444800L;
//Current time. Used to determine future GMToffset transitions
//Current time. Used to determine future GMT offset transitions
private static final long CURRT = System.currentTimeMillis()/1000;
/**
@ -482,7 +482,7 @@ public final class ZoneInfoFile {
for (; i < savingsInstantTransitions.length; i++) {
long trans = savingsInstantTransitions[i];
if (trans > UTC2037) {
if (trans > UTC2100) {
// no trans beyond LASTYEAR
lastyear = LASTYEAR;
break;
@ -629,11 +629,11 @@ public final class ZoneInfoFile {
}
} else if (nTrans > 0) { // only do this if there is something in table already
if (lastyear < LASTYEAR) {
// ZoneInfo has an ending entry for 2037
// ZoneInfo has an ending entry for 2100
//long trans = OffsetDateTime.of(LASTYEAR, 1, 1, 0, 0, 0, 0,
// ZoneOffset.ofTotalSeconds(rawOffset/1000))
// .toEpochSecond();
long trans = LDT2037 - rawOffset/1000;
long trans = LDT2100 - rawOffset/1000;
int offsetIndex = indexOf(offsets, 0, nOffsets, rawOffset/1000);
if (offsetIndex == nOffsets)
@ -814,7 +814,9 @@ public final class ZoneInfoFile {
private static final long DST_MASK = 0xf0L;
private static final int DST_NSHIFT = 4;
private static final int TRANSITION_NSHIFT = 12;
private static final int LASTYEAR = 2037;
// The `last` year that transitions are accounted for. If there are
// rules that go beyond this LASTYEAR, the value needs to be expanded.
private static final int LASTYEAR = 2100;
// from: 0 for offset lookup, 1 for dstsvings lookup
private static int indexOf(int[] offsets, int from, int nOffsets, int offset) {