+sub tztest {
+ my ($calspec, $last) = @_;
+ my $spec = PVE::CalendarEvent::parse_calendar_event($calspec);
+ return PVE::CalendarEvent::compute_next_event($spec, $last);
+}
+
+# Test loop termination at CEST/CET switch (cannot happen here in UTC)
+is(tztest('mon..fri', timelocal(0, 0, 0, 28, 9, 2018)),
+ timelocal(0, 0, 0, 29, 9, 2018));
+is(tztest('mon..fri UTC', timelocal(0, 0, 0, 28, 9, 2018)),
+ timelocal(0, 0, 0, 29, 9, 2018));
+
+# Now in the affected time zone
+$ENV{TZ} = ':Europe/Vienna';
+POSIX::tzset();
+is(tztest('mon..fri', timelocal(0, 0, 0, 28, 9, 2018)),
+ timelocal(0, 0, 0, 29, 9, 2018));
+# Specifically requesting UTC in the calendar spec means the resulting output
+# time as seen locally (timelocal() as opposed to timegm()) is shifted by 1
+# hour.
+is(tztest('mon..fri UTC', timelocal(0, 0, 0, 28, 9, 2018)),
+ timelocal(0, 0, 1, 29, 9, 2018));
+$ENV{TZ} = 'UTC';
+POSIX::tzset();
+