From a35ffb5d03a161cd144a30a9f8c3490678e3213a Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Tue, 17 Dec 2024 22:08:56 +0000 Subject: [PATCH] Backport #73091 to 24.10: Fixing timezone option of formatDateTime --- src/Functions/formatDateTime.cpp | 4 ++++ .../0_stateless/03286_format_datetime_timezones.reference | 5 +++++ .../queries/0_stateless/03286_format_datetime_timezones.sql | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 tests/queries/0_stateless/03286_format_datetime_timezones.reference create mode 100644 tests/queries/0_stateless/03286_format_datetime_timezones.sql diff --git a/src/Functions/formatDateTime.cpp b/src/Functions/formatDateTime.cpp index 56910804866..602c99ee369 100644 --- a/src/Functions/formatDateTime.cpp +++ b/src/Functions/formatDateTime.cpp @@ -538,6 +538,10 @@ private: *dest = '-'; offset = -offset; } + else + { + *dest = '+'; + } writeNumber2(dest + 1, offset / 3600); writeNumber2(dest + 3, offset % 3600 / 60); diff --git a/tests/queries/0_stateless/03286_format_datetime_timezones.reference b/tests/queries/0_stateless/03286_format_datetime_timezones.reference new file mode 100644 index 00000000000..8392f0a8335 --- /dev/null +++ b/tests/queries/0_stateless/03286_format_datetime_timezones.reference @@ -0,0 +1,5 @@ +Wednesday-0800 +Wednesday-0500 +Wednesday+0000 +Wednesday+0100 +Wednesday+0200 diff --git a/tests/queries/0_stateless/03286_format_datetime_timezones.sql b/tests/queries/0_stateless/03286_format_datetime_timezones.sql new file mode 100644 index 00000000000..66bb8ab5076 --- /dev/null +++ b/tests/queries/0_stateless/03286_format_datetime_timezones.sql @@ -0,0 +1,5 @@ +select formatDateTime(toDateTime64('2024-12-11 12:34:56.000', 3, 'US/Pacific'), '%W%z'); +select formatDateTime(toDateTime64('2024-12-11 12:34:56.000', 3, 'US/Eastern'), '%W%z'); +select formatDateTime(toDateTime64('2024-12-11 12:34:56.000', 3, 'UTC'), '%W%z'); +select formatDateTime(toDateTime64('2024-12-11 12:34:56.000', 3, 'Europe/Berlin'), '%W%z'); +select formatDateTime(toDateTime64('2024-12-11 12:34:56.000', 3, 'Europe/Athens'), '%W%z');