Skip to content

Commit 16ca633

Browse files
committed
ICU-23325 Add a test case for the VTimeZone RRULE-UNTIL format issue.
1 parent 1659052 commit 16ca633

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

icu4c/source/test/intltest/tzrulets.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ void TimeZoneRuleTest::runIndexedTest( int32_t index, UBool exec, const char* &n
140140
CASE(15, TestT6669);
141141
CASE(16, TestVTimeZoneWrapper);
142142
CASE(17, TestT8943);
143+
CASE(18, TestVTimeZoneRruleUntil);
143144
default: name = ""; break;
144145
}
145146
}
@@ -2656,6 +2657,26 @@ TimeZoneRuleTest::TestT8943() {
26562657
delete rbtz;
26572658
}
26582659

2660+
// ICU-23325 UNTIL value in RRULE should be in ISO 8601 UTC format (e.g. 20211031T080000Z)
2661+
// instead of local time (e.g. 20211031T020000).
2662+
void
2663+
TimeZoneRuleTest::TestVTimeZoneRruleUntil() {
2664+
IcuTestErrorCode ec(*this, "TestVTimeZoneRruleUntil");
2665+
LocalPointer<VTimeZone> vtz(VTimeZone::createVTimeZoneByID("America/Chihuahua"));
2666+
UDate start = getUTCMillis(2020, UCAL_JANUARY, 1);
2667+
// // RRULE lines for rule changes in 2022
2668+
UnicodeString rrule1 = UnicodeString("RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;UNTIL=20211031T080000Z");
2669+
UnicodeString rrule2 = UnicodeString("RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=20220403T090000Z");
2670+
2671+
UnicodeString vtzData;
2672+
vtz->write(start, vtzData, ec);
2673+
ec.assertSuccess();
2674+
if (vtzData.indexOf(rrule1) < 0 ||
2675+
vtzData.indexOf(rrule2) < 0) {
2676+
errln("FAIL: RRULE UNTIL value is not in ISO 8601 UTC format");
2677+
}
2678+
}
2679+
26592680
#endif /* #if !UCONFIG_NO_FORMATTING */
26602681

26612682
//eof

icu4c/source/test/intltest/tzrulets.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class TimeZoneRuleTest : public CalendarTimeZoneTest {
4040
void TestT6669();
4141
void TestVTimeZoneWrapper();
4242
void TestT8943();
43+
void TestVTimeZoneRruleUntil();
4344

4445
private:
4546
void verifyTransitions(BasicTimeZone& icutz, UDate start, UDate end);

icu4j/main/core/src/test/java/com/ibm/icu/dev/test/timezone/TimeZoneRuleTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,4 +2241,25 @@ public void TestT8943() {
22412241
errln("Fail: Exception thrown - " + e.getMessage());
22422242
}
22432243
}
2244+
2245+
// ICU-23325 UNTIL value in RRULE should be in ISO 8601 UTC format (e.g. 20211031T080000Z)
2246+
// instead of local time (e.g. 20211031T020000).
2247+
@Test
2248+
public void TestVTimeZoneRruleUntil() {
2249+
final VTimeZone vtz = VTimeZone.create("America/Chihuahua");
2250+
final long start = getUTCMillis(2022, Calendar.JANUARY, 1);
2251+
// RRULE lines for rule changes in 2022
2252+
final String rrule1 = "RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;UNTIL=20211031T080000Z";
2253+
final String rrule2 = "RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=20220403T090000Z";
2254+
2255+
try (StringWriter sw = new StringWriter()) {
2256+
vtz.write(sw, start);
2257+
String vtzStr = sw.toString();
2258+
logln(vtzStr);
2259+
assertTrue("Should contains " + rrule1, vtzStr.contains(rrule1));
2260+
assertTrue("Should contains " + rrule2, vtzStr.contains(rrule2));
2261+
} catch (IOException e) {
2262+
errln("IOException: " + e.getMessage());
2263+
}
2264+
}
22442265
}

0 commit comments

Comments
 (0)