mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Add toStableRelativeHourNum
This commit is contained in:
parent
5a36b99933
commit
d9fcd91875
@ -895,6 +895,19 @@ public:
|
||||
return toRelativeHourNum(lut[toLUTIndex(v)].date);
|
||||
}
|
||||
|
||||
/// The same formula is used for positive time (after Unix epoch) and negative time (before Unix epoch).
|
||||
/// It’s needed for correct work of dateDiff function.
|
||||
inline Time toStableRelativeHourNum(Time t) const
|
||||
{
|
||||
return (t + DATE_LUT_ADD + 86400 - offset_at_start_of_epoch) / 3600 - (DATE_LUT_ADD / 3600);
|
||||
}
|
||||
|
||||
template <typename DateOrTime>
|
||||
inline Time toStableRelativeHourNum(DateOrTime v) const
|
||||
{
|
||||
return toStableRelativeHourNum(lut[toLUTIndex(v)].date);
|
||||
}
|
||||
|
||||
inline Time toRelativeMinuteNum(Time t) const /// NOLINT
|
||||
{
|
||||
return (t + DATE_LUT_ADD) / 60 - (DATE_LUT_ADD / 60);
|
||||
|
@ -159,19 +159,19 @@ struct ToExtendedRelativeHourNumImpl
|
||||
|
||||
static inline Int64 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toRelativeHourNum(t);
|
||||
return time_zone.toStableRelativeHourNum(t);
|
||||
}
|
||||
static inline UInt32 execute(UInt32 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toRelativeHourNum(static_cast<time_t>(t));
|
||||
return time_zone.toStableRelativeHourNum(static_cast<time_t>(t));
|
||||
}
|
||||
static inline Int64 execute(Int32 d, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toRelativeHourNum(ExtendedDayNum(d));
|
||||
return time_zone.toStableRelativeHourNum(ExtendedDayNum(d));
|
||||
}
|
||||
static inline UInt32 execute(UInt16 d, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toRelativeHourNum(DayNum(d));
|
||||
return time_zone.toStableRelativeHourNum(DayNum(d));
|
||||
}
|
||||
|
||||
using FactorTransform = ZeroTransform;
|
||||
|
Loading…
Reference in New Issue
Block a user