mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Improvements based on review
This commit is contained in:
parent
367b314df6
commit
0771329bf3
@ -60,6 +60,7 @@ DateLUTImpl::DateLUTImpl(const std::string & time_zone_)
|
|||||||
offset_at_start_of_epoch = cctz_time_zone.lookup(cctz_time_zone.lookup(epoch).pre).offset;
|
offset_at_start_of_epoch = cctz_time_zone.lookup(cctz_time_zone.lookup(epoch).pre).offset;
|
||||||
offset_at_start_of_lut = cctz_time_zone.lookup(cctz_time_zone.lookup(lut_start).pre).offset;
|
offset_at_start_of_lut = cctz_time_zone.lookup(cctz_time_zone.lookup(lut_start).pre).offset;
|
||||||
offset_is_whole_number_of_hours_during_epoch = true;
|
offset_is_whole_number_of_hours_during_epoch = true;
|
||||||
|
offset_is_whole_number_of_minutes_during_epoch = true;
|
||||||
|
|
||||||
cctz::civil_day date = lut_start;
|
cctz::civil_day date = lut_start;
|
||||||
|
|
||||||
@ -108,6 +109,9 @@ DateLUTImpl::DateLUTImpl(const std::string & time_zone_)
|
|||||||
if (offset_is_whole_number_of_hours_during_epoch && start_of_day > 0 && start_of_day % 3600)
|
if (offset_is_whole_number_of_hours_during_epoch && start_of_day > 0 && start_of_day % 3600)
|
||||||
offset_is_whole_number_of_hours_during_epoch = false;
|
offset_is_whole_number_of_hours_during_epoch = false;
|
||||||
|
|
||||||
|
if (offset_is_whole_number_of_minutes_during_epoch && start_of_day > 0 && start_of_day % 60)
|
||||||
|
offset_is_whole_number_of_minutes_during_epoch = false;
|
||||||
|
|
||||||
/// If UTC offset was changed this day.
|
/// If UTC offset was changed this day.
|
||||||
/// Change in time zone without transition is possible, e.g. Moscow 1991 Sun, 31 Mar, 02:00 MSK to EEST
|
/// Change in time zone without transition is possible, e.g. Moscow 1991 Sun, 31 Mar, 02:00 MSK to EEST
|
||||||
cctz::time_zone::civil_transition transition{};
|
cctz::time_zone::civil_transition transition{};
|
||||||
|
@ -193,6 +193,7 @@ private:
|
|||||||
/// UTC offset at the beginning of the first supported year.
|
/// UTC offset at the beginning of the first supported year.
|
||||||
Time offset_at_start_of_lut;
|
Time offset_at_start_of_lut;
|
||||||
bool offset_is_whole_number_of_hours_during_epoch;
|
bool offset_is_whole_number_of_hours_during_epoch;
|
||||||
|
bool offset_is_whole_number_of_minutes_during_epoch;
|
||||||
|
|
||||||
/// Time zone name.
|
/// Time zone name.
|
||||||
std::string time_zone;
|
std::string time_zone;
|
||||||
@ -464,7 +465,7 @@ public:
|
|||||||
|
|
||||||
inline unsigned toSecond(Time t) const
|
inline unsigned toSecond(Time t) const
|
||||||
{
|
{
|
||||||
if (offset_is_whole_number_of_hours_during_epoch)
|
if (likely(offset_is_whole_number_of_minutes_during_epoch))
|
||||||
{
|
{
|
||||||
Time res = t % 60;
|
Time res = t % 60;
|
||||||
if (likely(res >= 0))
|
if (likely(res >= 0))
|
||||||
@ -478,15 +479,12 @@ public:
|
|||||||
if (time >= lut[index].time_at_offset_change())
|
if (time >= lut[index].time_at_offset_change())
|
||||||
time += lut[index].amount_of_offset_change();
|
time += lut[index].amount_of_offset_change();
|
||||||
|
|
||||||
Time res = time % 60;
|
return time % 60;
|
||||||
if (likely(res >= 0))
|
|
||||||
return res;
|
|
||||||
return res + 60;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned toMinute(Time t) const
|
inline unsigned toMinute(Time t) const
|
||||||
{
|
{
|
||||||
if (t >= 0 && offset_is_whole_number_of_hours_during_epoch)
|
if (likely(t >= 0 && offset_is_whole_number_of_hours_during_epoch))
|
||||||
return (t / 60) % 60;
|
return (t / 60) % 60;
|
||||||
|
|
||||||
/// To consider the DST changing situation within this day
|
/// To consider the DST changing situation within this day
|
||||||
|
Loading…
Reference in New Issue
Block a user