Add DATE_SECONDS_PER_DAY macro definition to replace the numeric literal 86400

This commit is contained in:
Victor Krasnov 2023-05-22 09:23:23 +00:00
parent a7b641134a
commit 98aace14ae
2 changed files with 3 additions and 1 deletions

View File

@ -10,6 +10,8 @@
#include <type_traits>
#define DATE_SECONDS_PER_DAY 86400 /// Number of seconds in a day, 60 * 60 * 24
#define DATE_LUT_MIN_YEAR 1900 /// 1900 since majority of financial organizations consider 1900 as an initial year.
#define DATE_LUT_MAX_YEAR 2299 /// Last supported year (complete)
#define DATE_LUT_YEARS (1 + DATE_LUT_MAX_YEAR - DATE_LUT_MIN_YEAR) /// Number of years in lookup table

View File

@ -300,7 +300,7 @@ struct ConvertImpl
if constexpr (std::is_same_v<ToDataType, DataTypeIPv4> && std::is_same_v<FromDataType, DataTypeUInt64>)
vec_to[i] = static_cast<ToFieldType>(static_cast<IPv4::UnderlyingType>(vec_from[i]));
else if constexpr (std::is_same_v<Name, NameToUnixTimestamp> && (std::is_same_v<FromDataType, DataTypeDate> || std::is_same_v<FromDataType, DataTypeDate32>))
vec_to[i] = static_cast<ToFieldType>(vec_from[i] * 86400);
vec_to[i] = static_cast<ToFieldType>(vec_from[i] * DATE_SECONDS_PER_DAY);
else
vec_to[i] = static_cast<ToFieldType>(vec_from[i]);
}