reports: use timezone-aware UTC for timestamps\n\n- Replace deprecated datetime.utcnow() with datetime.now(timezone.utc)\n- Keeps existing human-friendly format while avoiding deprecation warnings\n- Applies to marker file and generated_at in stats

This commit is contained in:
ngxstat-bot 2025-08-19 00:36:41 -05:00
commit 8eec623c92

View file

@ -3,7 +3,7 @@ import sqlite3
from pathlib import Path
import shutil
from typing import List, Dict, Optional
from datetime import datetime
from datetime import datetime, timezone
import time
import yaml
@ -37,7 +37,8 @@ def _cli_callback(ctx: typer.Context) -> None:
def _write_marker() -> None:
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
timestamp = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
# Use timezone-aware UTC to avoid deprecation warnings and ambiguity
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
GENERATED_MARKER.write_text(f"{timestamp}\n")
ctx.call_on_close(_write_marker)
@ -271,7 +272,8 @@ def _generate_global() -> None:
return
start_time = time.time()
generated_at = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
# Use timezone-aware UTC for generated_at (string remains unchanged format)
generated_at = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
_copy_icons()