Skip to content

Commit

Permalink
Fix all instances of utcnow()
Browse files Browse the repository at this point in the history
  • Loading branch information
pjrobertson committed Jan 14, 2025
1 parent 20726c1 commit 306df62
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/auto_archiver/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Metadata:
media: List[Media] = field(default_factory=list)

def __post_init__(self):
self.set("_processed_at", datetime.datetime.now(datetime.UTC))
self.set("_processed_at", datetime.datetime.now(datetime.timezone.utc))

def merge(self: Metadata, right: Metadata, overwrite_left=True) -> Metadata:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/auto_archiver/databases/gsheet_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def batch_if_valid(col, val, final_value=None):
media: Media = item.get_final_media()
if hasattr(media, "urls"):
batch_if_valid('archive', "\n".join(media.urls))
batch_if_valid('date', True, datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).isoformat())
batch_if_valid('date', True, datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=datetime.timezone.utc).isoformat())
batch_if_valid('title', item.get_title())
batch_if_valid('text', item.get("content", ""))
batch_if_valid('timestamp', item.get_timestamp())
Expand Down
2 changes: 1 addition & 1 deletion src/auto_archiver/enrichers/meta_enricher.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ def human_readable_bytes(self, size: int) -> str:
def enrich_archive_duration(self, to_enrich):
logger.debug(f"calculating archive duration for url={to_enrich.get_url()} ")

archive_duration = datetime.datetime.utcnow() - to_enrich.get("_processed_at")
archive_duration = datetime.datetime.now(datetime.timezone.utc) - to_enrich.get("_processed_at")
to_enrich.set("archive_duration_seconds", archive_duration.seconds)

0 comments on commit 306df62

Please sign in to comment.