Skip to content

Commit

Permalink
replace in format_ch_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr committed Sep 11, 2023
1 parent 78275f4 commit b684d6a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions posthog/queries/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from enum import Enum, auto
from typing import Any, Dict, Optional, Union

import pytz
from zoneinfo import ZoneInfo
from django.utils import timezone
from rest_framework.exceptions import ValidationError
Expand Down Expand Up @@ -77,9 +76,7 @@ def format_ch_timestamp(timestamp: datetime, convert_to_timezone: Optional[str]
# Then we convert it back to UTC (08:00 in UTC)
if timestamp.tzinfo and timestamp.tzinfo != ZoneInfo("UTC"):
raise ValidationError(detail="You must pass a timestamp with no timezone or UTC")
timestamp = (
pytz.timezone(convert_to_timezone).localize(timestamp.replace(tzinfo=None)).astimezone(ZoneInfo("UTC"))
)
timestamp = timestamp.replace(tzinfo=ZoneInfo(convert_to_timezone)).astimezone(ZoneInfo("UTC"))
return timestamp.strftime("%Y-%m-%d %H:%M:%S")


Expand Down

0 comments on commit b684d6a

Please sign in to comment.