Skip to content

Commit

Permalink
fix(snowflake): ensure that timestamps are properly timezoned
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jan 27, 2025
1 parent 8c7bc57 commit 452fd3a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ibis/formats/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,14 @@ def converter(value, dtype=dtype):
# TODO: can we do better than implicit truncation to microseconds?
import dateutil

value = datetime.datetime.fromtimestamp(value / 1e9, dateutil.tz.UTC)
value = pd.Timestamp.fromtimestamp(value / 1e9, dateutil.tz.UTC)

if (tz := dtype.timezone) is not None:
return value.astimezone(normalize_timezone(tz))
value = pd.Timestamp(value)
normed_tz = normalize_timezone(tz)
if value.tzinfo is None:
return value.tz_localize(normed_tz)
return pd.Timestamp(value).tz_convert(normed_tz)

return value.replace(tzinfo=None)

Expand Down

0 comments on commit 452fd3a

Please sign in to comment.