Skip to content

Commit

Permalink
ICU-22526 Allow GMT-23:59 time zone
Browse files Browse the repository at this point in the history
ECMA402 now allow offset timezone from -23:59 to 23:59.
We need to lower the minimum ZONE_OFFSET value to -23:59
  • Loading branch information
FrankYFTang committed Oct 3, 2023
1 parent 3446660 commit 6ff4f52
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion icu4c/source/i18n/calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ static const int32_t kCalendarLimits[UCAL_FIELD_COUNT][4] = {
{ 0, 0, 59, 59 }, // MINUTE
{ 0, 0, 59, 59 }, // SECOND
{ 0, 0, 999, 999 }, // MILLISECOND
{-16*kOneHour, -16*kOneHour, 12*kOneHour, 30*kOneHour }, // ZONE_OFFSET
{-24*kOneHour, -16*kOneHour, 12*kOneHour, 30*kOneHour }, // ZONE_OFFSET
{ -1*kOneHour, -1*kOneHour, 2*kOneHour, 2*kOneHour }, // DST_OFFSET
{/*N/A*/-1, /*N/A*/-1, /*N/A*/-1, /*N/A*/-1}, // YEAR_WOY
{ 1, 1, 7, 7 }, // DOW_LOCAL
Expand Down
10 changes: 10 additions & 0 deletions icu4c/source/test/intltest/tztest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ void TimeZoneTest::runIndexedTest( int32_t index, UBool exec, const char* &name,
TESTCASE_AUTO(TestCasablancaNameAndOffset22041);
TESTCASE_AUTO(TestRawOffsetAndOffsetConsistency22041);
TESTCASE_AUTO(TestGetIanaID);
TESTCASE_AUTO(TestGMTMinus24ICU22526);
TESTCASE_AUTO_END;
}

Expand Down Expand Up @@ -2664,4 +2665,13 @@ void TimeZoneTest::TestGetIanaID() {
}
}
}

void TimeZoneTest::TestGMTMinus24ICU22526() {
UErrorCode status = U_ZERO_ERROR;
LocalPointer<TimeZone> tz(TimeZone::createTimeZone("GMT-23:59"), status);
U_ASSERT(U_SUCCESS(status));
GregorianCalendar gc(tz.orphan(), status);
gc.setTime(123456789, status);
gc.get(UCAL_MONTH, status);
}
#endif /* #if !UCONFIG_NO_FORMATTING */
1 change: 1 addition & 0 deletions icu4c/source/test/intltest/tztest.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class TimeZoneTest: public CalendarTimeZoneTest {
void TestGetIDForWindowsID();
void TestCasablancaNameAndOffset22041();
void TestRawOffsetAndOffsetConsistency22041();
void TestGMTMinus24ICU22526();

void TestGetIanaID();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4581,7 +4581,7 @@ public int getMinimalDaysInFirstWeek()
{ 0, 0, 59, 59 }, // MINUTE
{ 0, 0, 59, 59 }, // SECOND
{ 0, 0, 999, 999 }, // MILLISECOND
{-16*ONE_HOUR, -16*ONE_HOUR, 12*ONE_HOUR, 30*ONE_HOUR }, // ZONE_OFFSET
{-24*ONE_HOUR, -16*ONE_HOUR, 12*ONE_HOUR, 30*ONE_HOUR }, // ZONE_OFFSET
{ 0, 0, 2*ONE_HOUR, 2*ONE_HOUR }, // DST_OFFSET
{/* */}, // YEAR_WOY
{ 1, 1, 7, 7 }, // DOW_LOCAL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2419,6 +2419,13 @@ public void TestGetIanaID() {
}
}
}
@Test
public void TestGMTMinus24ICU22526() {
TimeZone tz = TimeZone.getTimeZone("GMT-23:59");
GregorianCalendar gc = new GregorianCalendar(tz);
gc.setTimeInMillis(123456789);
gc.get(GregorianCalendar.MONTH);
}
}

//eof

0 comments on commit 6ff4f52

Please sign in to comment.