Skip to content

Commit

Permalink
Merge pull request #56 from dachengx/master
Browse files Browse the repository at this point in the history
Set timezone to UTC to avoid Daylight Saving Time
  • Loading branch information
jmosbacher authored Feb 4, 2024
2 parents bf761dd + fcdaddf commit 5d18982
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rframe/indexes/interpolating_index.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytz
import datetime
from typing import Callable, Union

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5d18982

Please sign in to comment.