ソースを参照

Update to proper timezone

jherve 1 年間 前
コミット
7f86d76653

+ 1 - 2
src/de_quoi_parle_le_monde/internet_archive.py

@@ -63,7 +63,6 @@ class CdxRequest:
     limit: Optional[int] = None
 
     translation_dict: ClassVar[dict] = dict(from_="from", to_="to")
-    date_format: ClassVar[str] = "%Y%m%d"
     datetime_format: ClassVar[str] = "%Y%m%d%H%M%S"
 
     def into_params(self) -> dict[str, str]:
@@ -79,7 +78,7 @@ class CdxRequest:
     @classmethod
     def _stringify_value(cls, v) -> str:
         if isinstance(v, datetime):
-            return v.strftime(cls.datetime_format)
+            return v.astimezone(tz_utc).strftime(cls.datetime_format)
         else:
             return str(v)
 

+ 3 - 3
src/de_quoi_parle_le_monde/snapshots.py

@@ -42,8 +42,8 @@ class SnapshotSearchJob(Job):
 
     @staticmethod
     def last_n_days_at_hours(n: int, hours: list[int]) -> list[datetime]:
-        utc_tz = ZoneInfo("UTC")
-        now = datetime.now(utc_tz)
+        tz = ZoneInfo("Europe/Paris")
+        now = datetime.now(tz)
 
         return [
             dt
@@ -51,7 +51,7 @@ class SnapshotSearchJob(Job):
             for h in hours
             if (
                 dt := datetime.combine(
-                    date.today() - timedelta(days=i), time(hour=h), tzinfo=utc_tz
+                    date.today() - timedelta(days=i), time(hour=h), tzinfo=tz
                 )
             )
             < now