Skip to content

Commit

Permalink
fix utc bug
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 22, 2024
1 parent 6a727d5 commit 87a1517
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions bbot/scanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import regex as re
from pathlib import Path
from sys import exc_info
from datetime import datetime, UTC
from datetime import datetime
from zoneinfo import ZoneInfo
from collections import OrderedDict

from bbot import __version__
Expand Down Expand Up @@ -327,7 +328,7 @@ async def async_start_without_generator(self):

async def async_start(self):
""" """
self.start_time = datetime.now(UTC)
self.start_time = datetime.now(ZoneInfo("UTC"))
self.root_event.data["started_at"] = self.start_time.timestamp()
try:
await self._prep()
Expand Down Expand Up @@ -436,7 +437,7 @@ async def _mark_finished(self):
else:
status = "FINISHED"

self.end_time = datetime.now(UTC)
self.end_time = datetime.now(ZoneInfo("UTC"))
self.duration = self.end_time - self.start_time
self.duration_seconds = self.duration.total_seconds()
self.duration_human = self.helpers.human_timedelta(self.duration)
Expand Down
4 changes: 2 additions & 2 deletions bbot/test/test_step_1/test_db_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime, UTC
from datetime import datetime
from zoneinfo import ZoneInfo

from bbot.models.pydantic import Event
Expand All @@ -13,7 +13,7 @@ def test_pydantic_models(events):
now = datetime.now(ZoneInfo("America/New_York"))
utc_now = utc_datetime_validator(now)
assert now.timestamp() == utc_now.timestamp()
now2 = datetime.fromtimestamp(utc_now.timestamp(), UTC)
now2 = datetime.fromtimestamp(utc_now.timestamp(), ZoneInfo("UTC"))
assert now2.timestamp() == utc_now.timestamp()
utc_now2 = utc_datetime_validator(now2)
assert utc_now2.timestamp() == utc_now.timestamp()
Expand Down

0 comments on commit 87a1517

Please sign in to comment.