Commit 05a1d5b1 authored by Kantz's avatar Kantz
Browse files

zeitzohne nochmal angepasst

parent 0ae33edc
...@@ -4,7 +4,8 @@ import hashlib ...@@ -4,7 +4,8 @@ import hashlib
import json import json
import os import os
from glob import glob from glob import glob
from datetime import datetime, timezone from datetime import datetime
from zoneinfo import ZoneInfo
from threading import Lock from threading import Lock
from typing import Any from typing import Any
...@@ -30,12 +31,12 @@ def _resolve_latest_path(chat_id: str) -> str | None: ...@@ -30,12 +31,12 @@ def _resolve_latest_path(chat_id: str) -> str | None:
return None return None
def _utc_now() -> str: def _mez_now() -> str:
return datetime.now(timezone.mez).strftime("%Y-%m-%dT%H:%M:%SZ") return datetime.now(ZoneInfo("Europe/Berlin")).strftime("%Y-%m-%dT%H:%M:%SZ")
def _touch(sheet: dict[str, Any]) -> None: def _touch(sheet: dict[str, Any]) -> None:
sheet["updated_at"] = _utc_now() sheet["updated_at"] = _mez_now()
def touch_sheet(sheet: dict[str, Any]) -> None: def touch_sheet(sheet: dict[str, Any]) -> None:
...@@ -56,7 +57,7 @@ def get_chat_id(messages: list[dict], draft: str | None = None) -> str: ...@@ -56,7 +57,7 @@ def get_chat_id(messages: list[dict], draft: str | None = None) -> str:
def init_sheet_base(chat_id: str, messages: list[dict]) -> dict[str, Any]: def init_sheet_base(chat_id: str, messages: list[dict]) -> dict[str, Any]:
timestamp = _utc_now() timestamp = _mez_now()
return { return {
"chat_id": chat_id, "chat_id": chat_id,
"created_at": timestamp, "created_at": timestamp,
...@@ -190,7 +191,7 @@ def get_decisions(sheet: dict[str, Any]) -> list[dict[str, Any]]: ...@@ -190,7 +191,7 @@ def get_decisions(sheet: dict[str, Any]) -> list[dict[str, Any]]:
def add_decision(sheet: dict[str, Any], decision: dict[str, Any]) -> None: def add_decision(sheet: dict[str, Any], decision: dict[str, Any]) -> None:
entry = {"timestamp": _utc_now(), **decision} entry = {"timestamp": _mez_now(), **decision}
sheet.setdefault("decisions", []).append(entry) sheet.setdefault("decisions", []).append(entry)
_touch(sheet) _touch(sheet)
......
import json import json
import os import os
from datetime import datetime, timezone from datetime import datetime
from zoneinfo import ZoneInfo
def format_log_timestamp(created_at: str | None) -> str: def format_log_timestamp(created_at: str | None) -> str:
if not created_at: if not created_at:
return datetime.now(timezone.mez).strftime("%Y-%m-%dT%H:%M:%SZ") return datetime.now(ZoneInfo("Europe/Berlin")).strftime("%Y-%m-%dT%H:%M:%SZ")
try: try:
parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ") parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%SZ")
return parsed.strftime("%Y-%m-%dT%H:%M:%SZ") return parsed.strftime("%Y-%m-%dT%H:%M:%SZ")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment