mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Substitute missing year in parseDateTimeBestEffortImpl()
This commit is contained in:
parent
9f80900d6f
commit
6d25e5a0d7
@ -578,12 +578,16 @@ ReturnType parseDateTimeBestEffortImpl(
|
|||||||
if (!year && !month && !day_of_month && !has_time)
|
if (!year && !month && !day_of_month && !has_time)
|
||||||
return on_error(ErrorCodes::CANNOT_PARSE_DATETIME, "Cannot read DateTime: neither Date nor Time was parsed successfully");
|
return on_error(ErrorCodes::CANNOT_PARSE_DATETIME, "Cannot read DateTime: neither Date nor Time was parsed successfully");
|
||||||
|
|
||||||
if (!year)
|
|
||||||
year = 2000;
|
|
||||||
if (!month)
|
|
||||||
month = 1;
|
|
||||||
if (!day_of_month)
|
if (!day_of_month)
|
||||||
day_of_month = 1;
|
day_of_month = 1;
|
||||||
|
if (!month)
|
||||||
|
month = 1;
|
||||||
|
if (!year)
|
||||||
|
{
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
UInt16 curr_year = local_time_zone.toYear(now);
|
||||||
|
year = now < local_time_zone.makeDateTime(year, month, day_of_month, hour, minute, second) ? curr_year - 1 : curr_year;
|
||||||
|
}
|
||||||
|
|
||||||
auto is_leap_year = (year % 400 == 0) || (year % 100 != 0 && year % 4 == 0);
|
auto is_leap_year = (year % 400 == 0) || (year % 100 != 0 && year % 4 == 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user