From b8cbedee27a49601210a6e265db69a78534d974b Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 18 Sep 2018 21:31:43 +0300 Subject: [PATCH] Merging #2770 --- dbms/src/Functions/FunctionsDateTime.h | 7 ++++--- dbms/tests/queries/0_stateless/00718_format_datetime.sql | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dbms/src/Functions/FunctionsDateTime.h b/dbms/src/Functions/FunctionsDateTime.h index 3c9dfb601c2..c80cf66b2e0 100644 --- a/dbms/src/Functions/FunctionsDateTime.h +++ b/dbms/src/Functions/FunctionsDateTime.h @@ -1570,6 +1570,7 @@ public: } }; + /** formatDateTime(time, 'pattern') * Performs formatting of time, according to provided pattern */ @@ -1582,8 +1583,6 @@ private: FormattingOperation(const char * source, size_t copy_source, size_t copy_length) : source(source), source_position_to_copy(copy_source), source_length_to_copy(copy_length) {} - FormattingOperation(const char * source) : source(source) {} - void (*operation)(char *&, UInt32, const DateLUTImpl &) = nullptr; private: @@ -1698,9 +1697,11 @@ private: static void format_I(char *& target, UInt32 source, const DateLUTImpl & timezone) { auto x = ToHourImpl::execute(source, timezone); - writeNumber2(target, x > 12 ? x - 12 : x); + writeNumber2(target, x == 0 ? 12 : (x > 12 ? x - 12 : x)); } + /// TODO format_l + static void format_j(char *& target, UInt32 source, const DateLUTImpl & timezone) { writeNumberWidth(target, ToDayOfYearImpl::execute(source, timezone), 3); diff --git a/dbms/tests/queries/0_stateless/00718_format_datetime.sql b/dbms/tests/queries/0_stateless/00718_format_datetime.sql index b218ba013a7..5e40a3ce088 100644 --- a/dbms/tests/queries/0_stateless/00718_format_datetime.sql +++ b/dbms/tests/queries/0_stateless/00718_format_datetime.sql @@ -1,3 +1,5 @@ +SET send_logs_level = 'none'; + SELECT formatDateTime(); -- { serverError 42 } SELECT formatDateTime('not a datetime', 'IGNORED'); -- { serverError 43 } SELECT formatDateTime(now(), now()); -- { serverError 43 }