Skip to content

Commit 72bb513

Browse files
committed
Added test case for DST taking place
1 parent 6e10a50 commit 72bb513

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Ical.Net.Tests/MatchTimeZoneTests.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,21 @@ public void MatchTimeZone_LocalTimeUsaWithTimeZone()
5858
}
5959

6060
[Test, Category("Recurrence")]
61-
public void MatchTimeZone_LocalTimeAustraliaWithTimeZone()
61+
[TestCase("20241005T140000Z", 5)]
62+
[TestCase("20241005T150000Z", 6)]
63+
public void MatchTimeZone_LocalTimeAustraliaWithTimeZone(string inputUntil, int expectedOccurrences)
6264
{
6365
// DTSTART with local time and time zone reference (positive offset), UNTIL as UTC
64-
const string ical =
65-
"""
66+
var ical =
67+
$"""
6668
BEGIN:VCALENDAR
6769
VERSION:2.0
6870
PRODID:-//Example Corp//NONSGML Event//EN
6971
BEGIN:VEVENT
7072
UID:example1
7173
SUMMARY:Event with local time and time zone
7274
DTSTART;TZID=Australia/Sydney:20241001T010000
73-
RRULE:FREQ=DAILY;UNTIL=20241005T140000Z
75+
RRULE:FREQ=DAILY;UNTIL={inputUntil}
7476
DTEND;TZID=Australia/Sydney:20241001T020000
7577
END:VEVENT
7678
END:VCALENDAR
@@ -80,23 +82,26 @@ public void MatchTimeZone_LocalTimeAustraliaWithTimeZone()
8082
var evt = calendar.Events.First();
8183
var until = evt.RecurrenceRules.First().Until;
8284

83-
var expectedUntil = new DateTime(2024, 10, 05, 14, 0, 0, DateTimeKind.Utc);
85+
var expectedUntil = DateTime.ParseExact(inputUntil, "yyyyMMddTHHmmssZ",
86+
System.Globalization.CultureInfo.InvariantCulture,
87+
System.Globalization.DateTimeStyles.AssumeUniversal |
88+
System.Globalization.DateTimeStyles.AdjustToUniversal);
8489
var occurrences = evt.GetOccurrences(new CalDateTime(2024, 10, 01), new CalDateTime(2024, 10, 07));
8590

8691
Assert.Multiple(() =>
8792
{
8893
Assert.That(until, Is.EqualTo(expectedUntil));
89-
Assert.That(occurrences.Count, Is.EqualTo(5));
94+
Assert.That(occurrences.Count, Is.EqualTo(expectedOccurrences));
9095
/*
91-
Should have 5 occurrences:
96+
Should have 5 occurrences with UNTIL=20241005T140000Z...
9297
October 1, 2024: 01:00 AM - 02:00 AM (UTC+1000) (Australia/Sydney)
9398
October 2, 2024: 01:00 AM - 02:00 AM (UTC+1000) (Australia/Sydney)
9499
October 3, 2024: 01:00 AM - 02:00 AM (UTC+1000) (Australia/Sydney)
95100
October 4, 2024: 01:00 AM - 02:00 AM (UTC+1000) (Australia/Sydney)
96101
October 5, 2024: 01:00 AM - 02:00 AM (UTC+1000) (Australia/Sydney)
97102
103+
... and 6 occurrences with UNTIL=20241005T150000Z, i.e. plus one more
98104
October 6, 2024: 01:00 AM - 02:00 AM (UTC+1100) (Australia/Sydney)
99-
must NOT be included, because 20241005T140000Z => October 6, 2024: 01:00 AM (Australia/Sydney)
100105
(Daylight Saving Time in Australia/Sydney starts on Sunday, October 6, 2024, at 2:00 AM)
101106
*/
102107
});

0 commit comments

Comments
 (0)