diff options
author | louiz’ <louiz@louiz.org> | 2016-09-17 00:34:28 +0200 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2016-09-17 00:34:28 +0200 |
commit | aaa2ca670ab5f19390e77a1f5ea88017b312ceaf (patch) | |
tree | e1fdeabcf8a9f1d045808de7f2fd00343d90286b | |
parent | a8d28a38d4f61ffef29b3bf2325db6d206cf73ac (diff) | |
download | biboumi-aaa2ca670ab5f19390e77a1f5ea88017b312ceaf.tar.gz biboumi-aaa2ca670ab5f19390e77a1f5ea88017b312ceaf.tar.bz2 biboumi-aaa2ca670ab5f19390e77a1f5ea88017b312ceaf.tar.xz biboumi-aaa2ca670ab5f19390e77a1f5ea88017b312ceaf.zip |
Fix the parse_datetime by using %Z instead of %z
If anybody knows why fedora accepts both, but it only works with %z on
debian, please tell me.
-rw-r--r-- | louloulibs/utils/time.cpp | 4 | ||||
-rw-r--r-- | tests/utils.cpp | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/louloulibs/utils/time.cpp b/louloulibs/utils/time.cpp index 305b2ad..bc8b3f8 100644 --- a/louloulibs/utils/time.cpp +++ b/louloulibs/utils/time.cpp @@ -15,10 +15,10 @@ std::string to_string(const std::time_t& timestamp) std::time_t parse_datetime(const std::string& stamp) { struct tm tm; - if (!::strptime(stamp.data(), "%FT%T%z", &tm)) + if (!::strptime(stamp.data(), "%FT%T%Z", &tm)) return -1; auto res = ::timegm(&tm); return res; } -}
\ No newline at end of file +} diff --git a/tests/utils.cpp b/tests/utils.cpp index 084a048..5913f8d 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -127,5 +127,7 @@ TEST_CASE("parse_datetime") const auto time = utils::parse_datetime("1970-01-01T00:00:00Z"); CHECK(time == 0); CHECK(utils::parse_datetime("2016-08-29T14:29:28Z") == 1472480968); + CHECK(utils::parse_datetime("2016-08-29T14:29:28UT") == 1472480968); + CHECK(utils::parse_datetime("2016-08-29T14:29:28GMT") == 1472480968); CHECK(utils::parse_datetime("blah") == -1); }
\ No newline at end of file |