Skip to content

Commit

Permalink
more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone committed Jan 7, 2025
1 parent 854052d commit 5d35199
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,21 @@ def _valiidate_data_type(cls, v):
def _validate_date(cls, v):
"""Validate the date."""
# pylint: disable=import-outside-toplevel
from pandas import to_datetime
from pytz import timezone
from pandas import to_datetime # noqa
from pytz import timezone, UTC

if isinstance(v, str):
dt = to_datetime(v, utc=True).tz_convert(timezone("America/New_York"))
else:
try:
dt = datetime.fromtimestamp(v / 1000, timezone.utc)
dt = datetime.fromtimestamp(v / 1000, UTC)
dt = dt.astimezone(timezone("America/New_York"))
except Exception:
if isinstance(v, (int, float)):
# Check if the timestamp is in nanoseconds and convert to seconds
if v > 1e12:
v = v / 1e9 # Convert nanoseconds to seconds
dt = datetime.fromtimestamp(v, timezone.utc)
dt = datetime.fromtimestamp(v, UTC)
dt = dt.astimezone(timezone("America/New_York"))
else:
dt = v
Expand Down

0 comments on commit 5d35199

Please sign in to comment.