Skip to content

Commit

Permalink
Accept the 'z' and 'Z' timezone in timestamp_from_string.
Browse files Browse the repository at this point in the history
The 'z' (or 'Z') timezone denotes UTC+00:00.
Fixes scylladb#4641.

Signed-off-by: Kamil Braun <kbraun@scylladb.com>
  • Loading branch information
kbr-scylla committed Jul 17, 2019
1 parent f769828 commit a1f300c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/types_test.cc
Expand Up @@ -248,6 +248,8 @@ void test_timestamp_like_string_conversions(data_type timestamp_type) {
BOOST_REQUIRE(timestamp_type->equal(timestamp_type->from_string("2015-07-02 23:00-0100"), timestamp_type->decompose(tp)));
BOOST_REQUIRE(timestamp_type->equal(timestamp_type->from_string("2015-07-03T00:00+0000"), timestamp_type->decompose(tp)));
BOOST_REQUIRE(timestamp_type->equal(timestamp_type->from_string("2015-07-03T01:00:00+0000"), timestamp_type->decompose(tp + 1h)));
BOOST_REQUIRE(timestamp_type->equal(timestamp_type->from_string("2015-07-03t00:00:00z"), timestamp_type->decompose(tp)));
BOOST_REQUIRE(timestamp_type->equal(timestamp_type->from_string("2015-07-03T00:00:00Z"), timestamp_type->decompose(tp)));
BOOST_REQUIRE(timestamp_type->equal(timestamp_type->from_string("2015-07-03T00:00:00.123+0000"), timestamp_type->decompose(tp + 123ms)));
BOOST_REQUIRE(timestamp_type->equal(timestamp_type->from_string("2015-07-03T12:30:00+1230"), timestamp_type->decompose(tp)));
BOOST_REQUIRE(timestamp_type->equal(timestamp_type->from_string("2015-07-02T23:00-0100"), timestamp_type->decompose(tp)));
Expand Down
2 changes: 1 addition & 1 deletion types.cc
Expand Up @@ -830,7 +830,7 @@ class timestamp_type_impl : public simple_type_impl<db_clock::time_point> {
auto t2 = local_tz::utc_to_local(t - tz_offset);
auto dst_offset = t2 - t;
t -= tz_offset + dst_offset;
} else {
} else if (tz != "z") {
throw marshal_exception(sprint("Unable to parse timezone '%s'", tz));
}
return (t - boost::posix_time::from_time_t(0)).total_milliseconds();
Expand Down

0 comments on commit a1f300c

Please sign in to comment.