used_check_files.clear();
} // eo remove_check_files
- void set_utc (void)
+ void set_tz (const std::string &tzname)
{
errno = 0;
- if (setenv ("TZ", "UTC", 1) == -1)
+ if (setenv ("TZ", tzname.c_str (), 1) == -1)
{
std::cerr
- << "error setting environment 'TZ': [" << this->tz << "]"
+ << "error setting environment 'TZ': [" << tzname << "]"
<< std::endl
;
return;
tzset ();
}
+ inline void set_utc (void)
+ {
+ this->set_tz ("UTC");
+ }
+
public:
TestTimeFuncFixture()
: tz (secure_getenv ("TZ") ?: "")
BOOST_AUTO_TEST_CASE(FormatFullTime)
{
+ this->set_tz ("CET");
time_t seconds = 1318844005;
BOOST_CHECK_EQUAL("17.10.2011 11:33", format_full_time(seconds));
BOOST_AUTO_TEST_CASE(DateToSeconds1)
{
+ this->set_tz ("CET");
// no DST
BOOST_CHECK_EQUAL(1325372400, date_to_seconds("2012-01-01"));
}
BOOST_AUTO_TEST_CASE(DateToSeconds2)
{
+ this->set_tz ("CET");
// DST
BOOST_CHECK_EQUAL(1341093600, date_to_seconds("2012-07-01"));
}
BOOST_AUTO_TEST_CASE(FormatISO8601_TZ_local)
{
+ this->set_tz ("CET");
const time_t moment = 1515492684;
BOOST_CHECK_EQUAL("11:11:24Z+0100",
format_iso8601 (moment, false, false, true, true));
BOOST_AUTO_TEST_CASE(FormatISO8601_DTZ_local)
{
+ this->set_tz ("CET");
const time_t moment = 1515492684;
BOOST_CHECK_EQUAL("2018-01-09T11:11:24Z+0100",
format_iso8601 (moment, false, true, true, true));