From 4c7226627c9155e0297a962c77b93dc4a75ab927 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 10 Jul 2014 22:53:09 +0400 Subject: [PATCH] dbms: fixed error with formatting of date-times with 1970-01-01 dates [#METR-11873]. --- .../0_stateless/00060_date_lut.reference | 1 + .../queries/0_stateless/00060_date_lut.sql | 1 + libs/libcommon/src/tests/date_lut4.cpp | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00060_date_lut.reference create mode 100644 dbms/tests/queries/0_stateless/00060_date_lut.sql create mode 100644 libs/libcommon/src/tests/date_lut4.cpp diff --git a/dbms/tests/queries/0_stateless/00060_date_lut.reference b/dbms/tests/queries/0_stateless/00060_date_lut.reference new file mode 100644 index 00000000000..aad30111128 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00060_date_lut.reference @@ -0,0 +1 @@ +1970-01-01 14:25:36 diff --git a/dbms/tests/queries/0_stateless/00060_date_lut.sql b/dbms/tests/queries/0_stateless/00060_date_lut.sql new file mode 100644 index 00000000000..1209be85fc5 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00060_date_lut.sql @@ -0,0 +1 @@ +SELECT toString(toDateTime('1970-01-01 14:25:36')) diff --git a/libs/libcommon/src/tests/date_lut4.cpp b/libs/libcommon/src/tests/date_lut4.cpp new file mode 100644 index 00000000000..0c6bcc82718 --- /dev/null +++ b/libs/libcommon/src/tests/date_lut4.cpp @@ -0,0 +1,20 @@ +#include +#include + + +int main(int argc, char ** argv) +{ + /** В DateLUT был глюк - для времён из дня 1970-01-01, возвращался номер часа больше 23. */ + static const time_t TIME = 66130; + + DateLUT & date_lut = DateLUT::instance(); + + std::cerr << date_lut.toHourInaccurate(TIME) << std::endl; + std::cerr << date_lut.toDayNum(TIME) << std::endl; + + const DateLUT::Values * values = reinterpret_cast(&date_lut); + + std::cerr << values[0].date << ", " << time_t(values[1].date - values[0].date) << std::endl; + + return 0; +}