|
|
@@ -0,0 +1,680 @@
|
|
|
+// Unit tests for the cron engine. Pure: no database, no network, no clock -
|
|
|
+// every timestamp here is constructed, so these run anywhere the compiler does.
|
|
|
+//
|
|
|
+// Why so many cases: validating an expression and firing on it are the same
|
|
|
+// code now, so a hole here is a schedule that validates on push and then never
|
|
|
+// fires, which looks exactly like a broken scheduler.
|
|
|
+#include <gtest/gtest.h>
|
|
|
+
|
|
|
+#include <cstdlib>
|
|
|
+#include <ctime>
|
|
|
+#include <string>
|
|
|
+#include <vector>
|
|
|
+
|
|
|
+#include "functions/cron.hpp"
|
|
|
+
|
|
|
+using svapi::functions::CronExpr;
|
|
|
+using svapi::functions::cronExpressionValid;
|
|
|
+
|
|
|
+namespace {
|
|
|
+
|
|
|
+/// A UTC timestamp from calendar parts. timegm, never mktime: a test that
|
|
|
+/// depended on the host's TZ would pass in CI and fail on a laptop.
|
|
|
+std::time_t utc(int year, int mon, int day, int hour, int min, int sec = 0) {
|
|
|
+ std::tm tm{};
|
|
|
+ tm.tm_year = year - 1900;
|
|
|
+ tm.tm_mon = mon - 1;
|
|
|
+ tm.tm_mday = day;
|
|
|
+ tm.tm_hour = hour;
|
|
|
+ tm.tm_min = min;
|
|
|
+ tm.tm_sec = sec;
|
|
|
+ return timegm(&tm);
|
|
|
+}
|
|
|
+
|
|
|
+std::string iso(std::time_t t) {
|
|
|
+ std::tm tm{};
|
|
|
+ gmtime_r(&t, &tm);
|
|
|
+ char buf[32];
|
|
|
+ std::strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%SZ", &tm);
|
|
|
+ return buf;
|
|
|
+}
|
|
|
+
|
|
|
+CronExpr ok(const std::string& expr) {
|
|
|
+ std::string err = "(no error reported)";
|
|
|
+ const std::optional<CronExpr> c = CronExpr::parse(expr, &err);
|
|
|
+ EXPECT_TRUE(c.has_value()) << "'" << expr << "' should parse: " << err;
|
|
|
+ return c.value_or(CronExpr{});
|
|
|
+}
|
|
|
+
|
|
|
+void bad(const std::string& expr) {
|
|
|
+ std::string err;
|
|
|
+ EXPECT_FALSE(CronExpr::parse(expr, &err).has_value()) << "'" << expr << "' should be rejected";
|
|
|
+ EXPECT_FALSE(err.empty()) << "'" << expr << "' rejected without an explanation";
|
|
|
+}
|
|
|
+
|
|
|
+} // namespace
|
|
|
+
|
|
|
+// ------------------------------------------------------------------ grammar
|
|
|
+
|
|
|
+TEST(Cron, AcceptsTheWholeGrammar) {
|
|
|
+ ok("* * * * *");
|
|
|
+ ok("0 0 1 1 0");
|
|
|
+ ok("59 23 31 12 6");
|
|
|
+ ok("*/5 * * * *");
|
|
|
+ ok("0,15,30,45 * * * *");
|
|
|
+ ok("0-59 0-23 1-31 1-12 0-7");
|
|
|
+ ok("1-5/2 * * * *");
|
|
|
+ ok("5/10 * * * *"); // a start value with a step, like Vixie cron
|
|
|
+ ok("0 3 * * 7"); // 7 is Sunday
|
|
|
+ ok("0 0 1 JAN MON");
|
|
|
+ ok("0 0 1 jan-dec sun-sat");
|
|
|
+ ok("0 0 1 Feb Fri");
|
|
|
+ ok(" 0 3 * * 0 "); // leading and trailing whitespace is not a field
|
|
|
+ ok("0\t3\t*\t*\t0"); // any whitespace separates
|
|
|
+ ok("0 3 * * 0"); // runs of whitespace collapse
|
|
|
+ ok("007 03 * * *"); // leading zeros are still digits
|
|
|
+ ok("0 0 29 2 *"); // Feb 29: fires only in a leap year, but legal
|
|
|
+ ok("*/1 */1 */1 */1 */1");
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, RejectsMalformedExpressions) {
|
|
|
+ bad("");
|
|
|
+ bad(" ");
|
|
|
+ bad("* * * *"); // four fields
|
|
|
+ bad("* * * * * *"); // six fields (no seconds field in this dialect)
|
|
|
+ bad("* * * * * * *");
|
|
|
+ bad("*/0 * * * *"); // a zero step would never fire
|
|
|
+ bad("* */0 * * *");
|
|
|
+ bad("5-1 * * * *"); // reversed range
|
|
|
+ bad("FRI-MON * * * 1-0");
|
|
|
+ bad("a * * * *"); // non-numeric, non-alias
|
|
|
+ bad("monday * * * *");
|
|
|
+ bad("* * * * monday"); // only the three-letter alias is accepted
|
|
|
+ bad("0, * * * *"); // trailing comma
|
|
|
+ bad(",0 * * * *"); // leading comma
|
|
|
+ bad("0,,30 * * * *"); // empty list item
|
|
|
+ bad("60 * * * *"); // out of range, every field
|
|
|
+ bad("* 24 * * *");
|
|
|
+ bad("* * 0 * *");
|
|
|
+ bad("* * 32 * *");
|
|
|
+ bad("* * * 0 *");
|
|
|
+ bad("* * * 13 *");
|
|
|
+ bad("* * * * 8");
|
|
|
+ bad("-5 * * * *");
|
|
|
+ bad("1-2-3 * * * *");
|
|
|
+ bad("* * * * 1-2-3");
|
|
|
+ bad("5/ * * * *"); // empty step
|
|
|
+ bad("5/2/3 * * * *"); // two steps
|
|
|
+ bad("*/x * * * *"); // non-numeric step
|
|
|
+ bad("*/100 * * * *"); // step longer than two digits is refused outright
|
|
|
+ bad("99999999999999999999 * * * *"); // must not throw on an absurd digit run
|
|
|
+ bad("* * JAN * *"); // month aliases do not apply to day-of-month
|
|
|
+ bad("* * * * JAN"); // nor month aliases to day-of-week
|
|
|
+ bad("SUN * * * *"); // nor day aliases to the minute field
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, ParseNeverThrowsAndToleratesANullError) {
|
|
|
+ // A script author's typo is data, not an exception. Also: `error` is
|
|
|
+ // documented as optional, so a caller that does not want the text must not
|
|
|
+ // crash the server.
|
|
|
+ EXPECT_NO_THROW({
|
|
|
+ EXPECT_FALSE(CronExpr::parse("totally bogus ! ? #", nullptr).has_value());
|
|
|
+ EXPECT_TRUE(CronExpr::parse("* * * * *", nullptr).has_value());
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, ValidHelperAgreesWithParse) {
|
|
|
+ std::string err;
|
|
|
+ EXPECT_TRUE(cronExpressionValid("0 3 * * *", &err));
|
|
|
+ EXPECT_TRUE(err.empty());
|
|
|
+ EXPECT_FALSE(cronExpressionValid("0 3 * *", &err));
|
|
|
+ EXPECT_FALSE(err.empty());
|
|
|
+ EXPECT_TRUE(cronExpressionValid("* * * * *", nullptr));
|
|
|
+ EXPECT_FALSE(cronExpressionValid("nope", nullptr));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, ErrorNamesTheOffendingField) {
|
|
|
+ std::string err;
|
|
|
+ CronExpr::parse("* * * 13 *", &err);
|
|
|
+ EXPECT_NE(err.find("month"), std::string::npos) << err;
|
|
|
+ CronExpr::parse("* * * *", &err);
|
|
|
+ EXPECT_NE(err.find("5"), std::string::npos) << err;
|
|
|
+}
|
|
|
+
|
|
|
+// ------------------------------------------------------------------ matches
|
|
|
+
|
|
|
+TEST(Cron, EveryMinuteMatchesEverything) {
|
|
|
+ const CronExpr c = ok("* * * * *");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 7, 13, 45)));
|
|
|
+ EXPECT_TRUE(c.matches(utc(2000, 1, 1, 0, 0)));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, SecondsAreIgnored) {
|
|
|
+ // Minute resolution: whether the scheduler ticks at :00 or :59 of the
|
|
|
+ // minute must not change the answer.
|
|
|
+ const CronExpr c = ok("30 4 * * *");
|
|
|
+ for (const int sec : {0, 1, 30, 59}) EXPECT_TRUE(c.matches(utc(2026, 3, 1, 4, 30, sec))) << sec;
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 3, 1, 4, 31, 0)));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, MatchesEachFieldIndependently) {
|
|
|
+ const CronExpr c = ok("30 4 15 6 *");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 6, 15, 4, 30)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 6, 15, 4, 31))); // minute
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 6, 15, 5, 30))); // hour
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 6, 16, 4, 30))); // day of month
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 7, 15, 4, 30))); // month
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, MatchesSteps) {
|
|
|
+ const CronExpr c = ok("*/15 * * * *");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 1, 1, 0, 0)));
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 1, 1, 0, 15)));
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 1, 1, 0, 30)));
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 1, 1, 0, 45)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 1, 1, 0, 1)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 1, 1, 0, 59)));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, MatchesRangeWithStep) {
|
|
|
+ const CronExpr c = ok("10-20/5 * * * *");
|
|
|
+ for (const int m : {10, 15, 20}) EXPECT_TRUE(c.matches(utc(2026, 1, 1, 0, m))) << m;
|
|
|
+ for (const int m : {9, 11, 14, 21, 25}) EXPECT_FALSE(c.matches(utc(2026, 1, 1, 0, m))) << m;
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, MatchesValueWithStep) {
|
|
|
+ // "50/4" means from 50 to the field maximum in fours, as Vixie cron reads
|
|
|
+ // it - not "50 only", and not every fourth minute of the hour.
|
|
|
+ const CronExpr c = ok("50/4 * * * *");
|
|
|
+ for (const int m : {50, 54, 58}) EXPECT_TRUE(c.matches(utc(2026, 1, 1, 0, m))) << m;
|
|
|
+ for (const int m : {0, 2, 46, 51, 59}) EXPECT_FALSE(c.matches(utc(2026, 1, 1, 0, m))) << m;
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, MatchesListsAndRanges) {
|
|
|
+ const CronExpr c = ok("0,30 9-17 * * *");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 1, 1, 9, 0)));
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 1, 1, 17, 30)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 1, 1, 18, 0)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 1, 1, 8, 59)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 1, 1, 12, 15)));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, MatchesMonthAliasesCaseInsensitively) {
|
|
|
+ const CronExpr c = ok("0 0 1 FeB,mar *");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 2, 1, 0, 0)));
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 3, 1, 0, 0)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 4, 1, 0, 0)));
|
|
|
+ // The alias must resolve to the same bit as the number.
|
|
|
+ const CronExpr n = ok("0 0 1 2,3 *");
|
|
|
+ for (const int mon : {1, 2, 3, 4, 12})
|
|
|
+ EXPECT_EQ(c.matches(utc(2026, mon, 1, 0, 0)), n.matches(utc(2026, mon, 1, 0, 0))) << mon;
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, MatchesDayOfWeekAliasesAndSevenAsSunday) {
|
|
|
+ // 2026-10-07 is a Wednesday; 2026-10-11 a Sunday.
|
|
|
+ EXPECT_TRUE(ok("0 0 * * WED").matches(utc(2026, 10, 7, 0, 0)));
|
|
|
+ EXPECT_FALSE(ok("0 0 * * WED").matches(utc(2026, 10, 8, 0, 0)));
|
|
|
+ EXPECT_TRUE(ok("0 0 * * 7").matches(utc(2026, 10, 11, 0, 0)));
|
|
|
+ EXPECT_TRUE(ok("0 0 * * 0").matches(utc(2026, 10, 11, 0, 0)));
|
|
|
+ EXPECT_TRUE(ok("0 0 * * SUN").matches(utc(2026, 10, 11, 0, 0)));
|
|
|
+ // A range that runs through 7 must still include Sunday and Friday.
|
|
|
+ const CronExpr c = ok("0 0 * * 5-7");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 9, 0, 0))); // Friday
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 10, 0, 0))); // Saturday
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 11, 0, 0))); // Sunday
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 10, 12, 0, 0))); // Monday
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, EverythingIsUtcNotLocalTime) {
|
|
|
+ // Pin the TZ to something far from UTC: the answer must not move. A server
|
|
|
+ // that changed hosts would otherwise silently reschedule everything.
|
|
|
+ const char* const old = getenv("TZ");
|
|
|
+ setenv("TZ", "Pacific/Kiritimati", 1); // UTC+14
|
|
|
+ tzset();
|
|
|
+ const CronExpr c = ok("0 0 * * *");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 7, 0, 0)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 10, 7, 14, 0)));
|
|
|
+ EXPECT_EQ(c.nextFire(utc(2026, 10, 7, 0, 0)), utc(2026, 10, 8, 0, 0));
|
|
|
+ if (old != nullptr) {
|
|
|
+ setenv("TZ", old, 1);
|
|
|
+ } else {
|
|
|
+ unsetenv("TZ");
|
|
|
+ }
|
|
|
+ tzset();
|
|
|
+}
|
|
|
+
|
|
|
+// ------------------------------------------------- the dom/dow OR rule
|
|
|
+
|
|
|
+TEST(Cron, DomAndDowAreOredWhenBothRestricted) {
|
|
|
+ // "the 13th OR any Friday", not "Friday the 13th". The single most
|
|
|
+ // commonly got-wrong rule in cron.
|
|
|
+ const CronExpr c = ok("0 0 13 * FRI");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 13, 0, 0))); // a Tuesday the 13th
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 9, 0, 0))); // a Friday, not the 13th
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 11, 13, 0, 0))); // a Friday the 13th: both
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 10, 14, 0, 0))); // neither
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, DomOnlyIsAndedWithAStarDow) {
|
|
|
+ const CronExpr c = ok("0 0 13 * *");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 13, 0, 0)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 10, 9, 0, 0))); // a Friday must NOT fire
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, DowOnlyIsAndedWithAStarDom) {
|
|
|
+ const CronExpr c = ok("0 0 * * FRI");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 9, 0, 0)));
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 10, 13, 0, 0))); // the 13th must NOT fire
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, OrRuleAlsoAppliesToRangesAndLists) {
|
|
|
+ const CronExpr c = ok("0 0 1,15 * MON-TUE");
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 1, 0, 0))); // the 1st, a Thursday
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 15, 0, 0))); // the 15th, a Thursday
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 5, 0, 0))); // a Monday
|
|
|
+ EXPECT_TRUE(c.matches(utc(2026, 10, 6, 0, 0))); // a Tuesday
|
|
|
+ EXPECT_FALSE(c.matches(utc(2026, 10, 7, 0, 0))); // Wednesday the 7th
|
|
|
+ // The month field still ANDs, even under the OR rule: it is not a day field.
|
|
|
+ const CronExpr m = ok("0 0 13 7 FRI");
|
|
|
+ EXPECT_TRUE(m.matches(utc(2026, 7, 13, 0, 0)));
|
|
|
+ EXPECT_TRUE(m.matches(utc(2026, 7, 10, 0, 0))); // a Friday in July
|
|
|
+ EXPECT_FALSE(m.matches(utc(2026, 8, 13, 0, 0))); // the 13th, wrong month
|
|
|
+ EXPECT_FALSE(m.matches(utc(2026, 8, 14, 0, 0))); // a Friday, wrong month
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireHonoursTheOrRule) {
|
|
|
+ const CronExpr c = ok("0 0 13 * FRI");
|
|
|
+ // From the 9th (a Friday) the next hit is the 13th, not the next Friday.
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 9, 0, 0)).value()), iso(utc(2026, 10, 13, 0, 0)));
|
|
|
+ // From the 13th the next hit is the following Friday, the 16th.
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 13, 0, 0)).value()), iso(utc(2026, 10, 16, 0, 0)));
|
|
|
+}
|
|
|
+
|
|
|
+// ----------------------------------------------------------------- nextFire
|
|
|
+
|
|
|
+TEST(Cron, NextFireIsStrictlyAfter) {
|
|
|
+ const CronExpr c = ok("* * * * *");
|
|
|
+ const std::time_t t = utc(2026, 10, 7, 13, 45);
|
|
|
+ EXPECT_EQ(c.nextFire(t), utc(2026, 10, 7, 13, 46));
|
|
|
+ // Mid-minute input rounds up to the next whole minute, never back to the
|
|
|
+ // minute it is already inside.
|
|
|
+ EXPECT_EQ(c.nextFire(utc(2026, 10, 7, 13, 45, 1)), utc(2026, 10, 7, 13, 46));
|
|
|
+ EXPECT_EQ(c.nextFire(utc(2026, 10, 7, 13, 45, 59)), utc(2026, 10, 7, 13, 46));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireAlwaysLandsOnAWholeMinute) {
|
|
|
+ const std::time_t t = ok("*/7 * * * *").nextFire(utc(2026, 10, 7, 13, 45, 23)).value();
|
|
|
+ EXPECT_EQ(t % 60, 0);
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireCrossesAnHourBoundary) {
|
|
|
+ const CronExpr c = ok("5 * * * *");
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 7, 13, 5)).value()), iso(utc(2026, 10, 7, 14, 5)));
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 7, 13, 6)).value()), iso(utc(2026, 10, 7, 14, 5)));
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 7, 13, 4)).value()), iso(utc(2026, 10, 7, 13, 5)));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireCrossesADayBoundary) {
|
|
|
+ const CronExpr c = ok("30 2 * * *");
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 7, 2, 30)).value()), iso(utc(2026, 10, 8, 2, 30)));
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 7, 23, 59)).value()), iso(utc(2026, 10, 8, 2, 30)));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireCrossesAMonthBoundary) {
|
|
|
+ const CronExpr c = ok("0 0 1 * *");
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 7, 12, 0)).value()), iso(utc(2026, 11, 1, 0, 0)));
|
|
|
+ // 31-day months only: the engine must skip February, April and so on.
|
|
|
+ const CronExpr d = ok("0 0 31 * *");
|
|
|
+ EXPECT_EQ(iso(d.nextFire(utc(2026, 1, 31, 0, 1)).value()), iso(utc(2026, 3, 31, 0, 0)));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireCrossesAYearBoundary) {
|
|
|
+ const CronExpr c = ok("0 0 1 1 *");
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2026, 10, 7, 12, 0)).value()), iso(utc(2027, 1, 1, 0, 0)));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireFindsLeapDay) {
|
|
|
+ const CronExpr c = ok("0 12 29 2 *");
|
|
|
+ // 2028 is the next leap year, which is inside the one-year bound from 2027.
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2027, 3, 1, 0, 0)).value()), iso(utc(2028, 2, 29, 12, 0)));
|
|
|
+ EXPECT_EQ(iso(c.nextFire(utc(2028, 1, 1, 0, 0)).value()), iso(utc(2028, 2, 29, 12, 0)));
|
|
|
+ // Just after it fires, the following one is four years out - beyond the
|
|
|
+ // bound, so the answer is "nothing scheduled", not a hang.
|
|
|
+ EXPECT_FALSE(c.nextFire(utc(2028, 2, 29, 12, 0)).has_value());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireReturnsNulloptForADateThatNeverExists) {
|
|
|
+ // Feb 30 parses - 30 is in range for day-of-month and 2 for month - and can
|
|
|
+ // never fire. Without the bound the search would spin forever.
|
|
|
+ EXPECT_FALSE(ok("0 0 30 2 *").nextFire(utc(2026, 1, 1, 0, 0)).has_value());
|
|
|
+ EXPECT_FALSE(ok("0 0 31 2 *").nextFire(utc(2026, 1, 1, 0, 0)).has_value());
|
|
|
+ // The OR rule rescues this one: Feb 30 never happens, but Monday does.
|
|
|
+ EXPECT_TRUE(ok("0 0 30 2 MON").nextFire(utc(2026, 1, 1, 0, 0)).has_value());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, NextFireIsConsistentWithMatchesOverManyMinutes) {
|
|
|
+ // The cheap property test: whatever nextFire returns must match, nothing
|
|
|
+ // between the start and that answer may match, and iterating it must walk
|
|
|
+ // the schedule. Catches a whole class of off-by-one.
|
|
|
+ const std::vector<std::string> exprs = {
|
|
|
+ "* * * * *", "*/7 * * * *", "0 0 * * *", "13 5 * * MON",
|
|
|
+ "0,30 9-17 * * 1-5", "59 23 31 12 *", "0 0 13 * FRI", "*/11 */3 1,15 1-6 *",
|
|
|
+ "45 */2 * * 0", "0 4 29 2 *",
|
|
|
+ };
|
|
|
+ for (const std::string& e : exprs) {
|
|
|
+ const CronExpr c = ok(e);
|
|
|
+ std::time_t t = utc(2026, 2, 26, 22, 51); // near a month and a day boundary
|
|
|
+ for (int i = 0; i < 40; ++i) {
|
|
|
+ const std::optional<std::time_t> n = c.nextFire(t);
|
|
|
+ if (!n.has_value()) break; // a bounded expression legitimately runs out
|
|
|
+ ASSERT_GT(n.value(), t) << e;
|
|
|
+ EXPECT_EQ(n.value() % 60, 0) << e;
|
|
|
+ EXPECT_TRUE(c.matches(n.value())) << e << " at " << iso(n.value());
|
|
|
+ // Nothing in between may match, which is what "first" means. Both
|
|
|
+ // edges of the gap are scanned and the middle of a very long one is
|
|
|
+ // skipped, because an off-by-one lives at an edge, not in the middle.
|
|
|
+ const std::time_t edge = 4000 * 60;
|
|
|
+ for (std::time_t m = t + 60; m < n.value(); m += 60) {
|
|
|
+ if (m > t + edge && m < n.value() - edge) {
|
|
|
+ m = n.value() - edge;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ASSERT_FALSE(c.matches(m)) << e << " skipped " << iso(m);
|
|
|
+ }
|
|
|
+ t = n.value();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+TEST(Cron, MatchesAndNextFireAgreeAcrossAFewHundredConsecutiveMinutes) {
|
|
|
+ // The other direction: walk real minutes and check that every matching one
|
|
|
+ // is reachable as the nextFire of the minute before it.
|
|
|
+ const std::vector<std::string> exprs = {"*/5 * * * *", "0 * * * *", "17 3 * * *",
|
|
|
+ "0 0 1,15 * SAT"};
|
|
|
+ for (const std::string& e : exprs) {
|
|
|
+ const CronExpr c = ok(e);
|
|
|
+ std::time_t t = utc(2026, 12, 31, 20, 0); // walk over a year boundary
|
|
|
+ for (int i = 0; i < 600; ++i, t += 60) {
|
|
|
+ if (!c.matches(t)) continue;
|
|
|
+ EXPECT_EQ(c.nextFire(t - 60), t) << e << " at " << iso(t);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ------------------------------------------------------- zone-aware matching
|
|
|
+//
|
|
|
+// These need the host tz database, which is the one thing here that is not
|
|
|
+// pure. That is the point: the answers must come from tzdata, so a test that
|
|
|
+// faked it would prove nothing. Every expectation is a real transition written
|
|
|
+// out as a UTC instant, so a tzdata update that moves one fails here rather
|
|
|
+// than quietly moving somebody's schedule.
|
|
|
+
|
|
|
+TEST(CronZone, AnEmptyZoneIsByteIdenticalToTheUtcPath) {
|
|
|
+ // The compatibility guarantee: existing schedules carry no zone and must
|
|
|
+ // keep meaning exactly what they meant. Checked by walking both entry
|
|
|
+ // points over a few thousand consecutive minutes across a northern DST
|
|
|
+ // transition, where a leaked local-time assumption would show up.
|
|
|
+ const std::vector<std::string> exprs = {"* * * * *", "*/7 * * * *", "0 0 * * *",
|
|
|
+ "30 2 * * *", "13 5 * * MON", "0 0 13 * FRI"};
|
|
|
+ for (const std::string& e : exprs) {
|
|
|
+ const CronExpr c = ok(e);
|
|
|
+ std::time_t t = utc(2026, 3, 28, 20, 0);
|
|
|
+ for (int i = 0; i < 4000; ++i, t += 60) {
|
|
|
+ ASSERT_EQ(c.matches(t), c.matchesIn(t, "")) << e << " at " << iso(t);
|
|
|
+ }
|
|
|
+ for (const std::time_t from : {utc(2026, 3, 28, 20, 0), utc(2026, 3, 29, 1, 30),
|
|
|
+ utc(2026, 10, 25, 0, 0), utc(2026, 12, 31, 23, 59)}) {
|
|
|
+ EXPECT_EQ(c.nextFire(from), c.nextFireIn(from, "")) << e << " from " << iso(from);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, AnUnknownZoneNeverFiresInsteadOfFallingBackToUtc) {
|
|
|
+ // A silent UTC fallback would move somebody's 08:00 report by an hour and
|
|
|
+ // look like it worked. The descriptor write path refuses an unknown zone,
|
|
|
+ // so reaching here means a row predates that check; never firing is the
|
|
|
+ // conservative answer, and the scheduler logs it.
|
|
|
+ const CronExpr c = ok("* * * * *");
|
|
|
+ EXPECT_FALSE(c.matchesIn(utc(2026, 7, 1, 12, 0), "Europe/Atlantis"));
|
|
|
+ EXPECT_FALSE(c.nextFireIn(utc(2026, 7, 1, 12, 0), "Europe/Atlantis").has_value());
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, ADailyScheduleFiresAtLocalWallClockTime) {
|
|
|
+ // The bug this work exists for: 0 8 * * * with tz Europe/Budapest means
|
|
|
+ // 07:00 UTC in winter and 06:00 UTC in summer, not 08:00 UTC all year.
|
|
|
+ const CronExpr c = ok("0 8 * * *");
|
|
|
+ const std::string tz = "Europe/Budapest";
|
|
|
+
|
|
|
+ EXPECT_TRUE(c.matchesIn(utc(2026, 1, 15, 7, 0), tz)); // 08:00 CET
|
|
|
+ EXPECT_FALSE(c.matchesIn(utc(2026, 1, 15, 8, 0), tz));
|
|
|
+ EXPECT_TRUE(c.matchesIn(utc(2026, 7, 15, 6, 0), tz)); // 08:00 CEST
|
|
|
+ EXPECT_FALSE(c.matchesIn(utc(2026, 7, 15, 7, 0), tz));
|
|
|
+
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 1, 15, 0, 0), tz), utc(2026, 1, 15, 7, 0));
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 7, 15, 0, 0), tz), utc(2026, 7, 15, 6, 0));
|
|
|
+ // And it keeps meaning 08:00 local straight across the spring transition.
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 3, 28, 7, 0), tz), utc(2026, 3, 29, 6, 0));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, TheLocalDateDecidesTheDayFields) {
|
|
|
+ // 23:00 UTC is already the next day in Budapest, so a Monday-only schedule
|
|
|
+ // must fire on the Sunday-evening UTC instant that is Monday local.
|
|
|
+ const CronExpr c = ok("0 1 * * MON");
|
|
|
+ const std::string tz = "Europe/Budapest";
|
|
|
+ // 2026-07-06 is a Monday; 01:00 local is 23:00 UTC on Sunday the 5th.
|
|
|
+ EXPECT_TRUE(c.matchesIn(utc(2026, 7, 5, 23, 0), tz));
|
|
|
+ EXPECT_FALSE(c.matchesIn(utc(2026, 7, 6, 1, 0), tz));
|
|
|
+
|
|
|
+ // Same for day-of-month: the 1st local, not the 1st UTC.
|
|
|
+ const CronExpr d = ok("0 0 1 * *");
|
|
|
+ EXPECT_TRUE(d.matchesIn(utc(2026, 6, 30, 22, 0), tz)); // 2026-07-01 00:00 CEST
|
|
|
+ EXPECT_FALSE(d.matchesIn(utc(2026, 7, 1, 0, 0), tz));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, ANonHourOffsetIsRespectedToTheMinute) {
|
|
|
+ // Asia/Kathmandu is UTC+05:45. An implementation that assumed whole hours
|
|
|
+ // fires this 45 minutes off and passes every other test in this file.
|
|
|
+ const CronExpr c = ok("0 8 * * *");
|
|
|
+ const std::string tz = "Asia/Kathmandu";
|
|
|
+ EXPECT_TRUE(c.matchesIn(utc(2026, 6, 1, 2, 15), tz));
|
|
|
+ EXPECT_FALSE(c.matchesIn(utc(2026, 6, 1, 2, 0), tz));
|
|
|
+ EXPECT_FALSE(c.matchesIn(utc(2026, 6, 1, 3, 0), tz));
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 6, 1, 0, 0), tz), utc(2026, 6, 1, 2, 15));
|
|
|
+
|
|
|
+ // A minute-granular schedule in a :45 zone, to be sure the minute field is
|
|
|
+ // read from local wall clock and not from UTC.
|
|
|
+ const CronExpr m = ok("30 * * * *");
|
|
|
+ EXPECT_TRUE(m.matchesIn(utc(2026, 6, 1, 2, 45), tz)); // 08:30 local
|
|
|
+ EXPECT_FALSE(m.matchesIn(utc(2026, 6, 1, 2, 30), tz));
|
|
|
+}
|
|
|
+
|
|
|
+// ----------------------------------------------------------- the two DST cases
|
|
|
+
|
|
|
+TEST(CronZone, ASkippedLocalTimeStillFiresOnceAtTheEndOfTheGap) {
|
|
|
+ // Europe/Budapest 2026-03-29: 02:00 CET becomes 03:00 CEST at 01:00 UTC, so
|
|
|
+ // 02:30 local does not happen. Losing the run is the wrong answer - a
|
|
|
+ // nightly job that silently skips one night a year is a bug nobody finds.
|
|
|
+ const CronExpr c = ok("30 2 * * *");
|
|
|
+ const std::string tz = "Europe/Budapest";
|
|
|
+ const std::time_t gapEnd = utc(2026, 3, 29, 1, 0);
|
|
|
+
|
|
|
+ EXPECT_TRUE(c.matchesIn(gapEnd, tz));
|
|
|
+ // Once, and only at the gap end: no other minute that morning fires.
|
|
|
+ int fires = 0;
|
|
|
+ for (std::time_t t = utc(2026, 3, 28, 22, 0); t < utc(2026, 3, 29, 12, 0); t += 60)
|
|
|
+ if (c.matchesIn(t, tz)) ++fires;
|
|
|
+ EXPECT_EQ(fires, 1);
|
|
|
+
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 3, 28, 23, 0), tz), gapEnd);
|
|
|
+ // Having fired, the next one is the following day's real 02:30 CEST.
|
|
|
+ EXPECT_EQ(c.nextFireIn(gapEnd, tz), utc(2026, 3, 30, 0, 30));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, AWholeGapOfMatchingMinutesCollapsesToOneFire) {
|
|
|
+ // Every minute of the lost hour matches here. It must still be ONE run at
|
|
|
+ // the gap end, not sixty queued jobs.
|
|
|
+ const CronExpr c = ok("* 2 * * *");
|
|
|
+ const std::string tz = "Europe/Budapest";
|
|
|
+ const std::time_t gapEnd = utc(2026, 3, 29, 1, 0);
|
|
|
+
|
|
|
+ int fires = 0;
|
|
|
+ std::time_t only = 0;
|
|
|
+ for (std::time_t t = utc(2026, 3, 29, 0, 0); t < utc(2026, 3, 29, 2, 0); t += 60)
|
|
|
+ if (c.matchesIn(t, tz)) {
|
|
|
+ ++fires;
|
|
|
+ only = t;
|
|
|
+ }
|
|
|
+ EXPECT_EQ(fires, 1);
|
|
|
+ EXPECT_EQ(only, gapEnd);
|
|
|
+
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 3, 29, 0, 0), tz), gapEnd);
|
|
|
+ // And nothing more that day: 02:xx local never comes back.
|
|
|
+ EXPECT_EQ(c.nextFireIn(gapEnd, tz), utc(2026, 3, 30, 0, 0)); // 02:00 CEST next day
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, ARepeatedLocalTimeFiresOnceNotTwice) {
|
|
|
+ // Europe/Budapest 2026-10-25: 03:00 CEST becomes 02:00 CET at 01:00 UTC, so
|
|
|
+ // 02:30 local happens at 00:30 UTC and again at 01:30 UTC. A daily job must
|
|
|
+ // run once that day.
|
|
|
+ const CronExpr c = ok("30 2 * * *");
|
|
|
+ const std::string tz = "Europe/Budapest";
|
|
|
+
|
|
|
+ EXPECT_TRUE(c.matchesIn(utc(2026, 10, 25, 0, 30), tz)); // first, CEST
|
|
|
+ EXPECT_FALSE(c.matchesIn(utc(2026, 10, 25, 1, 30), tz)); // second, CET: not again
|
|
|
+
|
|
|
+ int fires = 0;
|
|
|
+ for (std::time_t t = utc(2026, 10, 24, 22, 0); t < utc(2026, 10, 25, 12, 0); t += 60)
|
|
|
+ if (c.matchesIn(t, tz)) ++fires;
|
|
|
+ EXPECT_EQ(fires, 1);
|
|
|
+
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 10, 25, 0, 0), tz), utc(2026, 10, 25, 0, 30));
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 10, 25, 0, 30), tz), utc(2026, 10, 26, 1, 30));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, TheRepeatedHourDoesNotRunTwiceForAnHourlySchedule) {
|
|
|
+ // An hourly job over the fold: 24 runs that day, not 25. The repeated wall
|
|
|
+ // clock hour is counted once, which is what "once per wall-clock hour"
|
|
|
+ // means and the position the time zone seam commits to.
|
|
|
+ const CronExpr c = ok("0 * * * *");
|
|
|
+ const std::string tz = "Europe/Budapest";
|
|
|
+ int fires = 0;
|
|
|
+ // The whole local day 2026-10-25 runs from 22:00 UTC on the 24th to 23:00
|
|
|
+ // UTC on the 25th, 25 hours of real time.
|
|
|
+ for (std::time_t t = utc(2026, 10, 24, 22, 0); t < utc(2026, 10, 25, 23, 0); t += 60)
|
|
|
+ if (c.matchesIn(t, tz)) ++fires;
|
|
|
+ EXPECT_EQ(fires, 24); // 00:00 through 23:00 local, each once
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, SouthernHemisphereTransitionsRunTheOtherWay) {
|
|
|
+ // Australia/Sydney gains an hour in October and loses it in April, the
|
|
|
+ // reverse of Europe. A hard-coded northern rule gets both of these wrong.
|
|
|
+ const CronExpr c = ok("30 2 * * *");
|
|
|
+ const std::string tz = "Australia/Sydney";
|
|
|
+
|
|
|
+ // 2026-10-04: 02:00 AEST becomes 03:00 AEDT at 16:00 UTC on the 3rd.
|
|
|
+ const std::time_t gapEnd = utc(2026, 10, 3, 16, 0);
|
|
|
+ EXPECT_TRUE(c.matchesIn(gapEnd, tz));
|
|
|
+ EXPECT_EQ(c.nextFireIn(utc(2026, 10, 3, 14, 0), tz), gapEnd);
|
|
|
+ int springFires = 0;
|
|
|
+ for (std::time_t t = utc(2026, 10, 3, 12, 0); t < utc(2026, 10, 4, 12, 0); t += 60)
|
|
|
+ if (c.matchesIn(t, tz)) ++springFires;
|
|
|
+ EXPECT_EQ(springFires, 1);
|
|
|
+
|
|
|
+ // 2026-04-05: 03:00 AEDT becomes 02:00 AEST at 16:00 UTC on the 4th, so
|
|
|
+ // 02:30 local happens at 15:30 and again at 16:30 UTC.
|
|
|
+ EXPECT_TRUE(c.matchesIn(utc(2026, 4, 4, 15, 30), tz));
|
|
|
+ EXPECT_FALSE(c.matchesIn(utc(2026, 4, 4, 16, 30), tz));
|
|
|
+ int autumnFires = 0;
|
|
|
+ for (std::time_t t = utc(2026, 4, 4, 12, 0); t < utc(2026, 4, 5, 12, 0); t += 60)
|
|
|
+ if (c.matchesIn(t, tz)) ++autumnFires;
|
|
|
+ EXPECT_EQ(autumnFires, 1);
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, ADailyScheduleFiresExactlyOncePerLocalDayAcrossBothTransitions) {
|
|
|
+ // The end-to-end statement of the whole feature: whatever the zone and
|
|
|
+ // whatever the transition, a daily schedule runs once a local day. Counted
|
|
|
+ // over the weeks containing each transition in both hemispheres, with the
|
|
|
+ // schedule set to the hour the transitions actually touch.
|
|
|
+ struct Case {
|
|
|
+ const char* zone;
|
|
|
+ int year;
|
|
|
+ int month;
|
|
|
+ int day;
|
|
|
+ };
|
|
|
+ for (const Case& k : {Case{"Europe/Budapest", 2026, 3, 26},
|
|
|
+ Case{"Europe/Budapest", 2026, 10, 22},
|
|
|
+ Case{"Australia/Sydney", 2026, 10, 1},
|
|
|
+ Case{"Australia/Sydney", 2026, 4, 2},
|
|
|
+ Case{"Asia/Kathmandu", 2026, 3, 26}}) {
|
|
|
+ const CronExpr c = ok("30 2 * * *");
|
|
|
+ // The window is seven local days, found through nextFireIn so the
|
|
|
+ // counting cannot be fooled by the hour the transition adds or removes.
|
|
|
+ std::optional<std::time_t> t = c.nextFireIn(utc(k.year, k.month, k.day, 0, 0), k.zone);
|
|
|
+ int fires = 0;
|
|
|
+ std::time_t last = 0;
|
|
|
+ for (int i = 0; i < 7 && t.has_value(); ++i) {
|
|
|
+ ++fires;
|
|
|
+ last = t.value();
|
|
|
+ t = c.nextFireIn(last, k.zone);
|
|
|
+ }
|
|
|
+ EXPECT_EQ(fires, 7) << k.zone;
|
|
|
+ // Seven fires span six days of local time, give or take the DST hour.
|
|
|
+ const std::time_t first =
|
|
|
+ c.nextFireIn(utc(k.year, k.month, k.day, 0, 0), k.zone).value_or(0);
|
|
|
+ EXPECT_GE(last - first, 6 * 24 * 3600 - 3600) << k.zone;
|
|
|
+ EXPECT_LE(last - first, 6 * 24 * 3600 + 3600) << k.zone;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, NextFireAlwaysMatchesInTheSameZone) {
|
|
|
+ // The property test. Whatever nextFireIn returns must matchIn, nothing
|
|
|
+ // between may matchIn, and iterating it must walk the schedule. Run across
|
|
|
+ // both transitions in several zones, including one with a :45 offset and
|
|
|
+ // the empty (UTC) zone.
|
|
|
+ const std::vector<std::string> zones = {"Europe/Budapest", "Australia/Sydney",
|
|
|
+ "Asia/Kathmandu", "UTC", ""};
|
|
|
+ const std::vector<std::string> exprs = {"* * * * *", "*/7 * * * *", "30 2 * * *",
|
|
|
+ "0 8 * * *", "0,30 9-17 * * 1-5",
|
|
|
+ "59 23 31 12 *", "0 0 13 * FRI", "45 */2 * * 0"};
|
|
|
+ const std::vector<std::time_t> starts = {utc(2026, 3, 28, 23, 0), utc(2026, 10, 24, 23, 0),
|
|
|
+ utc(2026, 4, 4, 14, 0), utc(2026, 10, 3, 14, 0)};
|
|
|
+ for (const std::string& z : zones) {
|
|
|
+ for (const std::string& e : exprs) {
|
|
|
+ const CronExpr c = ok(e);
|
|
|
+ for (const std::time_t start : starts) {
|
|
|
+ std::time_t t = start;
|
|
|
+ for (int i = 0; i < 20; ++i) {
|
|
|
+ const std::optional<std::time_t> n = c.nextFireIn(t, z);
|
|
|
+ if (!n.has_value()) break;
|
|
|
+ ASSERT_GT(n.value(), t) << e << " in '" << z << "'";
|
|
|
+ ASSERT_EQ(n.value() % 60, 0) << e << " in '" << z << "'";
|
|
|
+ ASSERT_TRUE(c.matchesIn(n.value(), z))
|
|
|
+ << e << " in '" << z << "' at " << iso(n.value());
|
|
|
+ // Nothing in between may match, which is what "first"
|
|
|
+ // means. Only walked when the gap is short enough to walk;
|
|
|
+ // a yearly schedule's gap is covered by the cases above.
|
|
|
+ if (n.value() - t <= 3 * 24 * 3600) {
|
|
|
+ for (std::time_t m = t + 60; m < n.value(); m += 60)
|
|
|
+ ASSERT_FALSE(c.matchesIn(m, z))
|
|
|
+ << e << " in '" << z << "' skipped " << iso(m);
|
|
|
+ }
|
|
|
+ t = n.value();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+TEST(CronZone, NextFireReturnsNulloptForADateThatNeverExistsInAZoneToo) {
|
|
|
+ // The bound that stops a legal but impossible expression from spinning has
|
|
|
+ // to hold in the local-calendar walk as well.
|
|
|
+ EXPECT_FALSE(
|
|
|
+ ok("0 0 30 2 *").nextFireIn(utc(2026, 1, 1, 0, 0), "Europe/Budapest").has_value());
|
|
|
+ EXPECT_FALSE(
|
|
|
+ ok("0 0 31 2 *").nextFireIn(utc(2026, 1, 1, 0, 0), "Australia/Sydney").has_value());
|
|
|
+ // But a leap day is found, in local time, within the bound.
|
|
|
+ const std::optional<std::time_t> leap =
|
|
|
+ ok("0 4 29 2 *").nextFireIn(utc(2027, 3, 1, 0, 0), "Europe/Budapest");
|
|
|
+ ASSERT_TRUE(leap.has_value());
|
|
|
+ EXPECT_EQ(leap.value(), utc(2028, 2, 29, 3, 0)); // 04:00 CET
|
|
|
+}
|