From 860c4a27bd571d2cb45c3d6639c21ab2cb429a10 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 20 Apr 2020 10:10:25 +0300 Subject: [PATCH] Fix for weird timezones --- base/common/DateLUTImpl.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/base/common/DateLUTImpl.h b/base/common/DateLUTImpl.h index ec32d62bcad..a4d4c700d37 100644 --- a/base/common/DateLUTImpl.h +++ b/base/common/DateLUTImpl.h @@ -95,14 +95,14 @@ private: /// UTC offset is from -12 to +14 in all known time zones. This requires checking only three indices. - if ((guess == 0 || t >= lut[guess].date) && t < lut[DayNum(guess + 1)].date) + if (t >= lut[guess].date && t < lut[DayNum(guess + 1)].date) return guess; /// Time zones that have offset 0 from UTC do daylight saving time change (if any) towards increasing UTC offset (example: British Standard Time). - if (offset_at_start_of_epoch >= 0) - return DayNum(guess + 1); + if (t < lut[guess].date) + return DayNum(guess - 1); - return DayNum(guess - 1); + return DayNum(guess + 1); } inline const Values & find(time_t t) const @@ -579,7 +579,7 @@ public: return t / 3600; /// Assume that if offset was fractional, then the fraction is the same as at the beginning of epoch. - /// NOTE This assumption is false for "Pacific/Pitcairn" time zone. + /// NOTE This assumption is false for "Pacific/Pitcairn" and "Pacific/Kiritimati" time zones. return (t + 86400 - offset_at_start_of_epoch) / 3600; }