Date
view release on metacpan or search on metacpan
- upgrade tests for catch-v3
5.2.9 07.09.2021
- fix compilation failure on some systems: clash with fucking C marco
5.2.8 13.07.2021
- internal improvements
5.2.7 02.07.2021
- add Date::strptime
- More correctly parse dates in ISO8601 YYYY-Www format
- fix compilation warnings
5.2.6 24.05.2021
- skip setenv test for buggy freebsd versions
5.2.5 13.05.2021
- bugfix: respect timezones in DateRel ctor from two dates
5.2.4 19.04.2021
- add MANIFEST.SKIP
5.2.3 08.04.2021
- move C codes to own lib with cmake
- several bugfixes
- make Date thread-safe
- date objects in localzone (created with null tomezine), now follows tzset() (after they are changed)
5.2.2 25.11.2020
clib/tests/time/full.cc view on Meta::CPAN
CHECK(test_timegm(0, 200, 200000));
CHECK(test_timegm(0, 200, 200000));
}
TEST_CASE("full-localtime", "[.]") {
X64ONLY;
auto old = tzdir();
use_system_timezones();
for (auto tzname : {"Europe/Moscow", "America/New_York", "Australia/Melbourne"}) {
setenv("TZ", tzname, 1);
panda::time::tzset();
::tzset();
// check past
CHECK(test_localtime(39, epoch_from(1879), epoch_from(1881)));
// check transitions
CHECK(test_localtime(299, epoch_from(1980), epoch_from(1986)));
CHECK(test_localtime(299, epoch_from(2000), epoch_from(2006)));
CHECK(test_localtime(59, epoch_from(2000), epoch_from(2001)));
// check near future
clib/tests/time/full.cc view on Meta::CPAN
// check far future
CHECK(test_localtime(299, epoch_from(2060), epoch_from(2066)));
CHECK(test_localtime(59, epoch_from(2066), epoch_from(2067)));
// negative check
CHECK(test_localtime(59, epoch_from(-1000), epoch_from(-999)));
// random check
CHECK(test_localtime(0, 1500000000, 1000000));
CHECK(test_localtime(0, 20000000000, 1000000));
}
unsetenv("TZ");
tzdir(old);
}
TEST_CASE("full-timelocal", "[.]") {
X64ONLY;
auto old = tzdir();
use_system_timezones();
// Europe/Moscow disabled - system's timelocal has a lot of bugs with non-standart transitions which occur in Moscow
for (auto tzname : {"America/New_York", "Australia/Melbourne"}) {
setenv("TZ", tzname, 1);
panda::time::tzset();
::tzset();
// check past - unavailable, system's timelocal cannot work with these dates
// check transitions
CHECK(test_timelocal(86399, epoch_from(1910), epoch_from(1986)));
CHECK(test_timelocal(3599, epoch_from(1980), epoch_from(1986)));
CHECK(test_timelocal(3599, epoch_from(2000), epoch_from(2006)));
CHECK(test_timelocal(3599, epoch_from(2006), epoch_from(2011)));
// check near future
CHECK(test_timelocal(3599, epoch_from(2016), epoch_from(2022)));
// check far future
CHECK(test_timelocal(3599, epoch_from(2060), epoch_from(2066)));
// random check
CHECK(test_timelocal(0, 200, 400000));
}
unsetenv("TZ");
tzdir(old);
}
TEST_CASE("full-leapzone", "[.]") {
X64ONLY;
auto old = tzdir();
use_system_timezones();
Dias dias = {
// check past - unavailable, OS's timelocal cannot work with these dates
clib/tests/time/full.cc view on Meta::CPAN
{1, epoch_from(1995,12,31,12,00,00), epoch_from(1996,01,01,12,00,00)},
{1, epoch_from(1997,06,30,12,00,00), epoch_from(1997,07,01,12,00,00)},
{1, epoch_from(1998,12,31,12,00,00), epoch_from(1999,01,01,12,00,00)},
{1, epoch_from(2005,12,31,12,00,00), epoch_from(2006,01,01,12,00,00)},
{1, epoch_from(2008,12,31,12,00,00), epoch_from(2009,01,01,12,00,00)},
{1, epoch_from(2012,06,30,12,00,00), epoch_from(2012,07,01,12,00,00)}
};
for (auto tzname : {"right/UTC", "right/America/New_York", "right/Australia/Melbourne"}) {
DYNAMIC_SECTION(tzname) {
setenv("TZ", tzname, 1);
panda::time::tzset();
::tzset();
if (tzlocal()->name != tzname) {
WARN("SKIPPED, leap zone " << tzname << " not found in system");
continue;
}
for (auto& dia : dias) {
INFO("step=" << dia.step << ", from=" << dia.from << ", till=" << dia.till);
CHECK(test_localtime(dia.step, dia.from, dia.till));
CHECK(test_timelocal(dia.step, dia.from, dia.till));
}
// random check
CHECK(test_localtime(0, 1500000000, 5000000));
CHECK(test_timelocal(0, 120, 1000000));
}
}
unsetenv("TZ");
tzdir(old);
}
static void test_all_zones (int part) {
const int parts = 9;
X64ONLY;
auto old = tzdir();
use_system_timezones();
// many OS have bugs in localtime/timelocal implementations which prevent them from working correctly with listed time zones in our time periods
clib/tests/time/full.cc view on Meta::CPAN
auto tzlist = available_timezones();
std::sort(tzlist.begin(), tzlist.end(), [](auto a, auto b) { return a < b; });
for (size_t i = part-1; i < tzlist.size(); i += parts) {
auto tzname = tzlist[i];
if (buggy_zones.count(tzname)) continue;
if (tzname.find("posix") == 0) continue;
bool leapzone = tzname.find("right") == 0;
setenv("TZ", tzname.c_str(), 1);
panda::time::tzset();
::tzset();
DYNAMIC_SECTION(tzname) {
// check past
CHECK(test_localtime(3599, epoch_from(1980), epoch_from(1986)));
CHECK(test_timelocal(3599, epoch_from(1980), epoch_from(1986)));
// check transitions
CHECK(test_localtime(3599, epoch_from(2000), epoch_from(2006)));
CHECK(test_timelocal(3599, epoch_from(2000), epoch_from(2006)));
clib/tests/time/full.cc view on Meta::CPAN
CHECK(test_timelocal(3599, epoch_from(2016), epoch_from(2022)));
// check far future
if (!leapzone) { // skip testing future in leap second zones (OS has bugs)
CHECK(test_localtime(3599, epoch_from(2060), epoch_from(2066)));
CHECK(test_timelocal(3599, epoch_from(2060), epoch_from(2066)));
}
}
}
unsetenv("TZ");
tzdir(old);
}
TEST_CASE("full-zones-1", "[.]") { test_all_zones(1); }
TEST_CASE("full-zones-2", "[.]") { test_all_zones(2); }
TEST_CASE("full-zones-3", "[.]") { test_all_zones(3); }
TEST_CASE("full-zones-4", "[.]") { test_all_zones(4); }
TEST_CASE("full-zones-5", "[.]") { test_all_zones(5); }
TEST_CASE("full-zones-6", "[.]") { test_all_zones(6); }
TEST_CASE("full-zones-7", "[.]") { test_all_zones(7); }
clib/tests/time/tz.cc view on Meta::CPAN
TEST("tzset") {
tzset("Europe/Moscow");
CHECK(tzlocal()->name == "Europe/Moscow");
tzset(tzget("America/New_York"));
CHECK(tzlocal()->name == "America/New_York");
}
#ifndef TEST_NO_SETENV
TEST("tzset via ENV{TZ}") {
setenv("TZ", "Europe/Moscow", 1);
panda::time::tzset();
CHECK(tzlocal()->name == "Europe/Moscow");
setenv("TZ", "America/New_York", 1);
panda::time::tzset();
CHECK(tzlocal()->name == "America/New_York");
unsetenv("TZ");
panda::time::tzset();
CHECK(tzlocal()->name);
}
#endif
TEST("tzdir") {
auto now = ::time(NULL);
tzset("Europe/Moscow");
CHECK(tzlocal()->name == "Europe/Moscow");
( run in 0.928 second using v1.01-cache-2.11-cpan-3989ada0592 )