mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #10513 from ClickHouse/fix-fractional-timezones-overflow
Fix overflow at beginning of unix epoch for fractional timezones
This commit is contained in:
commit
11bb3e3afa
@ -287,8 +287,8 @@ public:
|
||||
if (offset_is_whole_number_of_hours_everytime)
|
||||
return (t / 60) % 60;
|
||||
|
||||
time_t date = find(t).date;
|
||||
return (t - date) / 60 % 60;
|
||||
UInt32 date = find(t).date;
|
||||
return (UInt32(t) - date) / 60 % 60;
|
||||
}
|
||||
|
||||
inline time_t toStartOfMinute(time_t t) const { return t / 60 * 60; }
|
||||
@ -301,9 +301,8 @@ public:
|
||||
if (offset_is_whole_number_of_hours_everytime)
|
||||
return t / 3600 * 3600;
|
||||
|
||||
time_t date = find(t).date;
|
||||
/// Still can return wrong values for time at 1970-01-01 if the UTC offset was non-whole number of hours.
|
||||
return date + (t - date) / 3600 * 3600;
|
||||
UInt32 date = find(t).date;
|
||||
return date + (UInt32(t) - date) / 3600 * 3600;
|
||||
}
|
||||
|
||||
/** Number of calendar day since the beginning of UNIX epoch (1970-01-01 is zero)
|
||||
|
@ -0,0 +1,3 @@
|
||||
1970-01-01 08:16:40
|
||||
16
|
||||
1970-01-01 08:00:00
|
@ -0,0 +1,3 @@
|
||||
SELECT toDateTime(10000, 'Asia/Calcutta');
|
||||
SELECT toMinute(toDateTime(10000, 'Asia/Calcutta'));
|
||||
SELECT toStartOfHour(toDateTime(10000, 'Asia/Calcutta'));
|
Loading…
Reference in New Issue
Block a user