diff --git a/java/yb-cql/src/test/java/org/yb/cql/TestTimestampDataType.java b/java/yb-cql/src/test/java/org/yb/cql/TestTimestampDataType.java index 522e540debff..a37e7264e07a 100644 --- a/java/yb-cql/src/test/java/org/yb/cql/TestTimestampDataType.java +++ b/java/yb-cql/src/test/java/org/yb/cql/TestTimestampDataType.java @@ -118,6 +118,10 @@ public void testInvalidInsert() throws Exception { runInvalidInsert(tableName, "1992-13-12"); runInvalidInsert(tableName, "1992-12-12 14:23:30:31"); runInvalidInsert(tableName, "1992-12-12 14:23:30.12.32"); + runInvalidInsert(tableName, "2017-12-21 00:00:01+0000"); + runInvalidInsert(tableName, "2017-12-21 00:00:01.000+123:30"); + runInvalidInsert(tableName, "2017-12-21 00:00:01.0000"); + runInvalidInsert(tableName, "2017-12-21 00:00:01.000000+0000"); } @Test diff --git a/src/yb/util/date_time.cc b/src/yb/util/date_time.cc index 136c9fe61e2e..a888fccc7c85 100644 --- a/src/yb/util/date_time.cc +++ b/src/yb/util/date_time.cc @@ -173,8 +173,12 @@ DateTimeInputFormat DateTime::CqlDateTimeInputFormat = []() -> DateTimeInputForm string time_fmt_no_sec = "(\\d{1,2}):(\\d{1,2})" + fmt_empty; string time_empty = fmt_empty + fmt_empty + fmt_empty; string frac_fmt = "\\.(\\d{1,3})"; - string tzX_fmt = "((?:\\+|-).+)"; - string tzZ_fmt = " (.+)"; + // Offset, i.e. +/-xx:xx + string tzX_fmt = "((?:\\+|-)\\d{2}:\\d{2})"; + // Timezone name, abbreviation, or offset (preceded by space), e.g. PDT, UDT+/-xx:xx, etc.. + // At this point this allows anything that starts with a letter or '+' (after space), and leaves + // further processing to the timezone parser. + string tzZ_fmt = " ([a-zA-Z\\+].+)"; // These cases match the valid Cassandra input formats vector regexes {