diff --git a/bbot/scanner/scanner.py b/bbot/scanner/scanner.py index a5b04bc2c..0915c4cb9 100644 --- a/bbot/scanner/scanner.py +++ b/bbot/scanner/scanner.py @@ -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__ @@ -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() @@ -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) diff --git a/bbot/test/test_step_1/test_db_models.py b/bbot/test/test_step_1/test_db_models.py index c29cc09a4..9c7139069 100644 --- a/bbot/test/test_step_1/test_db_models.py +++ b/bbot/test/test_step_1/test_db_models.py @@ -1,4 +1,4 @@ -from datetime import datetime, UTC +from datetime import datetime from zoneinfo import ZoneInfo from bbot.models.pydantic import Event @@ -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()