static const char *const formatter [ISO8601_SIZE] =
{ /* [iso8601::d ] = */ "%4Y-%m-%d",
/* [iso8601::t ] = */ "%T",
- /* [iso8601::tz ] = */ "%TZ%z",
+ /* [iso8601::tz ] = */ "%T%z",
/* [iso8601::dt ] = */ "%4Y-%m-%dT%T",
- /* [iso8601::dtz] = */ "%4Y-%m-%dT%TZ%z",
+ /* [iso8601::dtz] = */ "%4Y-%m-%dT%T%z",
};
static const char *const scanner [ISO8601_SIZE] =
{ /* [iso8601::d ] = */ "%Y-%m-%d",
/* [iso8601::t ] = */ "%T",
- /* [iso8601::tz ] = */ "%TZ%z",
+ /* [iso8601::tz ] = */ "%T%z",
/* [iso8601::dt ] = */ "%Y-%m-%dT%T",
- /* [iso8601::dtz] = */ "%Y-%m-%dT%TZ%z",
+ /* [iso8601::dtz] = */ "%Y-%m-%dT%T%z",
};
static inline const char *
}
/*
* Contrary to what the man page indicates, strptime(3) is *not*
- * the inverse operation of strftime(3)! The later correctly formats
+ * the inverse operation of strftime(3)! The latter correctly formats
* negative year numbers with the %F modifier wheres the former trips
* over the sign character.
*/
{
this->set_tz ("CET");
const time_t moment = 1515492684;
- BOOST_CHECK_EQUAL("11:11:24Z+0100",
+ BOOST_CHECK_EQUAL("11:11:24+0100",
format_iso8601 (moment, false, false, true, true));
}
BOOST_AUTO_TEST_CASE(FormatISO8601_TZ)
{
const time_t moment = 1515492684;
- BOOST_CHECK_EQUAL("10:11:24Z+0000",
+ BOOST_CHECK_EQUAL("10:11:24+0000",
format_iso8601 (moment, true, false, true, true));
}
{
this->set_tz ("CET");
const time_t moment = 1515492684;
- BOOST_CHECK_EQUAL("2018-01-09T11:11:24Z+0100",
+ BOOST_CHECK_EQUAL("2018-01-09T11:11:24+0100",
format_iso8601 (moment, false, true, true, true));
}
BOOST_AUTO_TEST_CASE(FormatISO8601_DTZ)
{
const time_t moment = 1515492684;
- BOOST_CHECK_EQUAL("2018-01-09T10:11:24Z+0000",
+ BOOST_CHECK_EQUAL("2018-01-09T10:11:24+0000",
format_iso8601 (moment, true, true, true, true));
}
helau.tm_gmtoff = 0;
helau.tm_zone = NULL;
- BOOST_CHECK_EQUAL("2018-11-11T11:11:11Z+0000",
+ BOOST_CHECK_EQUAL("2018-11-11T11:11:11+0000",
format_iso8601 (helau, true, true, true));
}
{
struct timespec ts = { 1541934671, 11 };
- BOOST_CHECK_EQUAL("2018-11-11T11:11:11Z+0000",
+ BOOST_CHECK_EQUAL("2018-11-11T11:11:11+0000",
format_iso8601 (ts, true, true, true, true));
}
I2n::clock::Time t (1541934671, 0);
boost::optional<std::string> s = t.format_iso8601 (true, true, true, true);
- BOOST_CHECK_EQUAL("2018-11-11T11:11:11Z+0000", *s);
+ BOOST_CHECK_EQUAL("2018-11-11T11:11:11+0000", *s);
}
BOOST_AUTO_TEST_CASE(Format_make_nice_time)
BOOST_AUTO_TEST_CASE(FromString_iso8601_full)
{
- const std::string in1 ("0001-01-01T00:00:00Z+0000");
- const std::string in2 ("2018-11-11T11:11:11Z+0000");
+ const std::string in1 ("0001-01-01T00:00:00+0000");
+ const std::string in2 ("2018-11-11T11:11:11+0000");
this->set_utc ();
BOOST_AUTO_TEST_CASE(FromString_iso8601_full_negyear)
{
- const std::string in1 ("-0001-01-01T00:00:00Z+0000");
- const std::string in2 ("-2018-11-11T11:11:11Z+0000");
+ const std::string in1 ("-0001-01-01T00:00:00+0000");
+ const std::string in2 ("-2018-11-11T11:11:11+0000");
this->set_utc ();
# endif
}
+ BOOST_AUTO_TEST_CASE(FromString_iso8601_Z)
+ {
+ const std::string in1 ("2019-04-25T13:41:47+0000");
+ const std::string in2 ("2019-04-25T13:41:47Z");
+
+ this->set_utc ();
+ boost::optional<I2n::clock::Time> t1 = I2n::clock::time_of_iso8601 (in1, true, true, true);
+ boost::optional<I2n::clock::Time> t2 = I2n::clock::time_of_iso8601 (in2, true, true, true);
+
+ BOOST_CHECK(t1);
+ BOOST_CHECK(t2);
+
+ BOOST_CHECK_EQUAL(*t1, *t2);
+ BOOST_CHECK_EQUAL(*t1->format_iso8601 (), *t2->format_iso8601 ());
+ BOOST_CHECK_EQUAL(*t2->format_iso8601 (), in1);
+ }
+
BOOST_AUTO_TEST_CASE(FromString_iso8601_partial)
{
const std::string in1 ("2018-11-11T11:11:11");