From fcdaddf67a6e6e55ca540de47877775439f88bef Mon Sep 17 00:00:00 2001 From: dachengx Date: Sun, 4 Feb 2024 11:32:11 -0600 Subject: [PATCH] Set timezone to UTC to avoid Daylight Saving Time --- rframe/indexes/interpolating_index.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rframe/indexes/interpolating_index.py b/rframe/indexes/interpolating_index.py index 32b4619..bfa5a87 100644 --- a/rframe/indexes/interpolating_index.py +++ b/rframe/indexes/interpolating_index.py @@ -1,3 +1,4 @@ +import pytz import datetime from typing import Callable, Union @@ -73,11 +74,11 @@ def reduce(self, docs, label): if not docs or label is None: return docs - x = label.replace(tzinfo=None).timestamp() if isinstance(label, datetime.datetime) else label + x = label.replace(tzinfo=pytz.utc).timestamp() if isinstance(label, datetime.datetime) else label xs = [self.validate_label(d[self.name]) for d in docs] # just convert all datetimes to timestamps to avoid complexity # FIXME: maybe properly handle timezones instead - xs = [xi.replace(tzinfo=None).timestamp() if isinstance(xi, datetime.datetime) else xi for xi in xs] + xs = [xi.replace(tzinfo=pytz.utc).timestamp() if isinstance(xi, datetime.datetime) else xi for xi in xs] if len(docs) == 1: new_document = docs[0] else: