* @copyright Copyright © 2001-2008 by Intra2net AG
*
*/
+#include <features.h>
+#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 23)
+/*
+ * Ancient glibc (pre 2015) has a defective implementation of strptime(3)
+ * that doesn’t handle the ‘Z’ modifier of ISO8601 to indicate UTC. It also
+ * parses fractional timezones only partially so e. g. “+11:11” is treated
+ * as “+1100”.
+ */
+# define GLIBC_STRPTIME_LACKS_Z
+#endif
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
# endif
}
+# ifndef GLIBC_STRPTIME_LACKS_Z
BOOST_AUTO_TEST_CASE(FromString_iso8601_Z)
{
const std::string in1 ("2019-04-25T13:41:47+0000");
BOOST_CHECK_EQUAL(*t1->format_iso8601 (), *t2->format_iso8601 ());
BOOST_CHECK_EQUAL(*t2->format_iso8601 (), in1);
}
+# endif
BOOST_AUTO_TEST_CASE(FromString_iso8601_partial)
{
boost::optional<I2n::clock::Time> t2 = I2n::clock::time_of_iso8601 (in2, true, true, true);
boost::optional<I2n::clock::Time> t3 = I2n::clock::time_of_iso8601 (in3, true, true, true);
+# ifdef GLIBC_STRPTIME_LACKS_Z
+ BOOST_CHECK(!t1);
+# else
BOOST_CHECK(t1);
+# endif
BOOST_CHECK(t2);
BOOST_CHECK(t3);
+# ifndef GLIBC_STRPTIME_LACKS_Z
BOOST_CHECK_EQUAL(*t1->format_iso8601 (), "2019-04-25T13:41:47+0000");
BOOST_CHECK_EQUAL(t1->get_sec (), 1556199707);
+# endif
BOOST_CHECK_EQUAL(*t2->format_iso8601 (), "2019-04-25T15:41:47+0000");
+# ifndef GLIBC_STRPTIME_LACKS_Z
BOOST_CHECK_EQUAL(t2->get_sec (), t1->get_sec () + 2 * 60 * 60);
+# endif
BOOST_CHECK_EQUAL(*t2, *t3);
BOOST_CHECK_EQUAL(*t3->format_iso8601 (), "2019-04-25T15:41:47+0000");
}