1 #include <msp/time/timedelta.h>
2 #include <msp/time/timezone.h>
3 #include <msp/test/test.h>
8 class TimeZoneTests: public Test::RegisteredTest<TimeZoneTests>
13 static const char *get_name() { return "TimeZone"; }
22 TimeZoneTests::TimeZoneTests()
24 add(&TimeZoneTests::utc, "UTC");
25 add(&TimeZoneTests::local, "Local");
26 add(&TimeZoneTests::custom, "Custom");
29 void TimeZoneTests::utc()
31 Time::TimeZone tz = Time::TimeZone::utc();
32 EXPECT_EQUAL(tz.get_name(), "UTC");
33 EXPECT_EQUAL(tz.get_offset(), Time::zero);
36 void TimeZoneTests::local()
38 Time::TimeZone tz = Time::TimeZone::local();
39 info(format("'%s' %s", tz.get_name(), tz.get_offset()));
42 void TimeZoneTests::custom()
44 Time::TimeZone tz1(120);
45 EXPECT_EQUAL(tz1.get_name(), "UTC+2");
46 Time::TimeZone tz2(345);
47 EXPECT_EQUAL(tz2.get_name(), "UTC+5:45");