Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions icu4c/source/test/intltest/tzrulets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ void TimeZoneRuleTest::runIndexedTest( int32_t index, UBool exec, const char* &n
CASE(15, TestT6669);
CASE(16, TestVTimeZoneWrapper);
CASE(17, TestT8943);
CASE(18, TestVTimeZoneRruleUntil);
default: name = ""; break;
}
}
Expand Down Expand Up @@ -2656,6 +2657,26 @@ TimeZoneRuleTest::TestT8943() {
delete rbtz;
}

// ICU-23325 UNTIL value in RRULE should be in ISO 8601 UTC format (e.g. 20211031T080000Z)
// instead of local time (e.g. 20211031T020000).
void
TimeZoneRuleTest::TestVTimeZoneRruleUntil() {
IcuTestErrorCode ec(*this, "TestVTimeZoneRruleUntil");
LocalPointer<VTimeZone> vtz(VTimeZone::createVTimeZoneByID("America/Chihuahua"));
UDate start = getUTCMillis(2020, UCAL_JANUARY, 1);
// // RRULE lines for rule changes in 2022
UnicodeString rrule1 = UnicodeString("RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;UNTIL=20211031T080000Z");
UnicodeString rrule2 = UnicodeString("RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=20220403T090000Z");

UnicodeString vtzData;
vtz->write(start, vtzData, ec);
ec.assertSuccess();
if (vtzData.indexOf(rrule1) < 0 ||
vtzData.indexOf(rrule2) < 0) {
errln("FAIL: RRULE UNTIL value is not in ISO 8601 UTC format");
}
}

#endif /* #if !UCONFIG_NO_FORMATTING */

//eof
1 change: 1 addition & 0 deletions icu4c/source/test/intltest/tzrulets.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TimeZoneRuleTest : public CalendarTimeZoneTest {
void TestT6669();
void TestVTimeZoneWrapper();
void TestT8943();
void TestVTimeZoneRruleUntil();

private:
void verifyTransitions(BasicTimeZone& icutz, UDate start, UDate end);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2241,4 +2241,26 @@ public void TestT8943() {
errln("Fail: Exception thrown - " + e.getMessage());
}
}

// ICU-23325 UNTIL value in RRULE should be in ISO 8601 UTC format (e.g. 20211031T080000Z)
// instead of local time (e.g. 20211031T020000).
@Test
public void TestVTimeZoneRruleUntil() {
final VTimeZone vtz = VTimeZone.create("America/Chihuahua");
final long start = getUTCMillis(2020, Calendar.JANUARY, 1);
// RRULE lines for rule changes in 2022
final String rrule1 = "RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;UNTIL=20211031T080000Z";
final String rrule2 = "RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=20220403T090000Z";

try (StringWriter sw = new StringWriter()) {
vtz.write(sw, start);
String vtzStr = sw.toString();
logln(vtzStr);
System.out.println(vtzStr);
assertTrue("Should contains " + rrule1, vtzStr.contains(rrule1));
assertTrue("Should contains " + rrule2, vtzStr.contains(rrule2));
} catch (IOException e) {
errln("IOException: " + e.getMessage());
}
}
}
Loading