mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Merge pull request #10369 from ClickHouse/fix-weird-timezones
Fix for weird timezones
This commit is contained in:
commit
fea7ee800a
@ -99,7 +99,7 @@ private:
|
||||
return guess;
|
||||
|
||||
/// Time zones that have offset 0 from UTC do daylight saving time change (if any) towards increasing UTC offset (example: British Standard Time).
|
||||
if (offset_at_start_of_epoch >= 0)
|
||||
if (t >= lut[DayNum(guess + 1)].date)
|
||||
return DayNum(guess + 1);
|
||||
|
||||
return DayNum(guess - 1);
|
||||
@ -579,7 +579,7 @@ public:
|
||||
return t / 3600;
|
||||
|
||||
/// Assume that if offset was fractional, then the fraction is the same as at the beginning of epoch.
|
||||
/// NOTE This assumption is false for "Pacific/Pitcairn" time zone.
|
||||
/// NOTE This assumption is false for "Pacific/Pitcairn" and "Pacific/Kiritimati" time zones.
|
||||
return (t + 86400 - offset_at_start_of_epoch) / 3600;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
2020-01-02 03:04:05 2020-01-02 00:00:00 3
|
||||
2020-01-02 03:04:05 2020-01-02 00:00:00 3
|
||||
2020-01-02 03:04:05 2020-01-02 00:00:00 3
|
||||
2020-01-02 03:04:05 2020-01-02 00:00:00 3
|
||||
2020-01-02 03:04:05 2020-01-02 00:00:00 3
|
||||
2020-01-02 03:04:05 2020-01-02 00:00:00 3
|
||||
2020-01-02 03:04:05 2020-01-02 00:00:00 3
|
15
tests/queries/0_stateless/01252_weird_time_zone.sql
Normal file
15
tests/queries/0_stateless/01252_weird_time_zone.sql
Normal file
@ -0,0 +1,15 @@
|
||||
SELECT toDateTime('2020-01-02 03:04:05', 'Pacific/Kiritimati') AS x, toStartOfDay(x), toHour(x);
|
||||
SELECT toDateTime('2020-01-02 03:04:05', 'Africa/El_Aaiun') AS x, toStartOfDay(x), toHour(x);
|
||||
SELECT toDateTime('2020-01-02 03:04:05', 'Asia/Pyongyang') AS x, toStartOfDay(x), toHour(x);
|
||||
SELECT toDateTime('2020-01-02 03:04:05', 'Pacific/Kwajalein') AS x, toStartOfDay(x), toHour(x);
|
||||
SELECT toDateTime('2020-01-02 03:04:05', 'Pacific/Apia') AS x, toStartOfDay(x), toHour(x);
|
||||
SELECT toDateTime('2020-01-02 03:04:05', 'Pacific/Enderbury') AS x, toStartOfDay(x), toHour(x);
|
||||
SELECT toDateTime('2020-01-02 03:04:05', 'Pacific/Fakaofo') AS x, toStartOfDay(x), toHour(x);
|
||||
|
||||
SELECT toHour(toDateTime(rand(), 'Pacific/Kiritimati') AS t) AS h, t FROM numbers(1000000) WHERE h < 0 OR h > 23 ORDER BY h LIMIT 1 BY h;
|
||||
SELECT toHour(toDateTime(rand(), 'Africa/El_Aaiun') AS t) AS h, t FROM numbers(1000000) WHERE h < 0 OR h > 23 ORDER BY h LIMIT 1 BY h;
|
||||
SELECT toHour(toDateTime(rand(), 'Asia/Pyongyang') AS t) AS h, t FROM numbers(1000000) WHERE h < 0 OR h > 23 ORDER BY h LIMIT 1 BY h;
|
||||
SELECT toHour(toDateTime(rand(), 'Pacific/Kwajalein') AS t) AS h, t FROM numbers(1000000) WHERE h < 0 OR h > 23 ORDER BY h LIMIT 1 BY h;
|
||||
SELECT toHour(toDateTime(rand(), 'Pacific/Apia') AS t) AS h, t FROM numbers(1000000) WHERE h < 0 OR h > 23 ORDER BY h LIMIT 1 BY h;
|
||||
SELECT toHour(toDateTime(rand(), 'Pacific/Enderbury') AS t) AS h, t FROM numbers(1000000) WHERE h < 0 OR h > 23 ORDER BY h LIMIT 1 BY h;
|
||||
SELECT toHour(toDateTime(rand(), 'Pacific/Fakaofo') AS t) AS h, t FROM numbers(1000000) WHERE h < 0 OR h > 23 ORDER BY h LIMIT 1 BY h;
|
Loading…
Reference in New Issue
Block a user