Skip to content

Commit

Permalink
Fix timezone in timestamp parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Bre77 committed Mar 5, 2024
1 parent 38af54c commit 27bb504
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions teslemetry_stream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
import json
import logging
from datetime import datetime
from datetime import datetime, timezone
from .const import TelemetryFields, TelemetryAlerts


Expand Down Expand Up @@ -192,7 +192,9 @@ async def __anext__(self) -> dict:
if self.parse_timestamp:
main, _, ns = data["createdAt"].partition(".")
data["timestamp"] = int(
datetime.strptime(main, "%Y-%m-%dT%H:%M:%S").timestamp()
datetime.strptime(main, "%Y-%m-%dT%H:%M:%S")
.replace(tzinfo=timezone.utc)
.timestamp()
) * 1000 + int(ns[:3])
LOGGER.debug("event %s", json.dumps(data))
return data
Expand Down

0 comments on commit 27bb504

Please sign in to comment.