Update public source

This commit is contained in:
2026-10-11 05:47:23 +03:00
parent d035b68f6f
commit d4548c0d46
2 changed files with 28 additions and 8 deletions
+25 -5
View File
@@ -10,7 +10,7 @@
по всему проекту.
"""
from pathlib import Path
from functools import lru_cache
import yaml
@@ -55,10 +55,30 @@ RECENT_SESSIONS_LIMIT = REPORTS_CONFIG.get(
10
)
TIMEZONE = CONFIG.get(
"timezone",
"Europe/Moscow"
)
TIMEZONE = CONFIG.get("timezone", "Europe/Moscow")
@lru_cache(maxsize=1)
def _load_timezone(mtime_ns, size):
with CONFIG_FILE.open("r", encoding="utf-8") as fp:
config = yaml.safe_load(fp) or {}
timezone_name = config.get("timezone", "Europe/Moscow")
if not isinstance(timezone_name, str) or not timezone_name:
return "Europe/Moscow"
return timezone_name
def get_timezone():
try:
stat = CONFIG_FILE.stat()
except OSError:
return "Europe/Moscow"
try:
return _load_timezone(stat.st_mtime_ns, stat.st_size)
except (OSError, yaml.YAMLError):
return TIMEZONE
# ============================================================
# Каталог отчёта
+3 -3
View File
@@ -26,7 +26,7 @@ from datetime import datetime, timezone
from pathlib import Path
from zoneinfo import ZoneInfo
from .config import TIMEZONE
from .config import get_timezone
# ============================================================
@@ -141,7 +141,7 @@ def format_datetime(
if dt is None:
return safe(text)
display_timezone = ZoneInfo(TIMEZONE)
display_timezone = ZoneInfo(get_timezone())
return dt.astimezone(
display_timezone
@@ -403,7 +403,7 @@ def modified(path):
if not path.exists():
return "-"
display_timezone = ZoneInfo(TIMEZONE)
display_timezone = ZoneInfo(get_timezone())
return datetime.fromtimestamp(
path.stat().st_mtime,