Fix timezone offset formatting

This commit is contained in:
Cory Levy 2022-08-29 20:40:11 -04:00
parent fe24bd9a7f
commit cd371110ad
2 changed files with 10 additions and 6 deletions

View File

@ -276,10 +276,13 @@ private:
{
auto offset = TimezoneOffsetImpl::execute(source, timezone);
if (offset < 0)
{
*target = '-';
offset = -offset;
}
writeNumber2(target + 1, ToHourImpl::execute(offset, timezone));
writeNumber2(target + 3, ToSecondImpl::execute(offset, timezone));
writeNumber2(target + 1, offset / 3600);
writeNumber2(target + 3, offset % 3600 / 60);
}
static void quarter(char * target, Time source, const DateLUTImpl & timezone)

View File

@ -42,8 +42,9 @@ SELECT formatDateTime(toDateTime('2018-01-02 22:33:44'), 'no formatting pattern'
SELECT formatDateTime(toDate('2018-01-01'), '%F %T');
SELECT
formatDateTime(toDateTime('2018-01-01 01:00:00', 'UTC'), '%F %T', 'UTC'),
formatDateTime(toDateTime('2018-01-01 01:00:00', 'UTC'), '%F %T', 'Asia/Istanbul')
formatDateTime(toDateTime('2018-01-01 01:00:00', 'UTC'), '%F %T', 'Asia/Istanbul');
SELECT formatDateTime(toDateTime('2020-01-01 01:00:00', 'UTC'), '%z')
SELECT formatDateTime(toDateTime('2020-01-01 01:00:00', 'US/Samoa'), '%z')
SELECT formatDateTime(toDateTime('2020-01-01 01:00:00', 'Europe/Moscow'), '%z')
SELECT formatDateTime(toDateTime('2020-01-01 01:00:00', 'UTC'), '%z');
SELECT formatDateTime(toDateTime('2020-01-01 01:00:00', 'US/Samoa'), '%z');
SELECT formatDateTime(toDateTime('2020-01-01 01:00:00', 'Europe/Moscow'), '%z');
SELECT formatDateTime(toDateTime('1970-01-01 00:00:00', 'IST'), '%z');