fix: report time in Brian's local timezone, not UTC
clock.stamp() (injected into her chat prompt via _now_note, and into reflection) rendered UTC and ignored the configured timezone, so 'what time is it' answered in UTC — hours off from his actual time, reading as 'she doesn't know the time'. Now converts to config.timezone (America/New_York -> EDT/EST), UTC fallback if the zone can't load. Storage stays UTC; this only changes what she reads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
-2
@@ -9,20 +9,33 @@ a long silence *means* to her is left to her own reflection, not prescribed here
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
|
from lyra import config
|
||||||
|
|
||||||
|
|
||||||
def now() -> datetime:
|
def now() -> datetime:
|
||||||
return datetime.now(timezone.utc)
|
return datetime.now(timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
|
def _local_tz() -> ZoneInfo | timezone:
|
||||||
|
"""Brian's configured local zone (falls back to UTC if it can't be loaded)."""
|
||||||
|
try:
|
||||||
|
return ZoneInfo(config.load().timezone)
|
||||||
|
except Exception:
|
||||||
|
return timezone.utc
|
||||||
|
|
||||||
|
|
||||||
def _parse(iso: str) -> datetime:
|
def _parse(iso: str) -> datetime:
|
||||||
dt = datetime.fromisoformat(iso)
|
dt = datetime.fromisoformat(iso)
|
||||||
return dt if dt.tzinfo else dt.replace(tzinfo=timezone.utc)
|
return dt if dt.tzinfo else dt.replace(tzinfo=timezone.utc)
|
||||||
|
|
||||||
|
|
||||||
def stamp(dt: datetime | None = None) -> str:
|
def stamp(dt: datetime | None = None) -> str:
|
||||||
"""Wall-clock stamp, e.g. 'Wednesday, 17 Jun 2026, 01:50 UTC'."""
|
"""Wall-clock stamp in Brian's local timezone, e.g.
|
||||||
return (dt or now()).strftime("%A, %d %b %Y, %H:%M UTC")
|
'Friday, 27 Jun 2026, 01:50 EDT'. Times are stored UTC; this is what she *reads*,
|
||||||
|
so 'what time is it' answers in his time, not UTC."""
|
||||||
|
return (dt or now()).astimezone(_local_tz()).strftime("%A, %d %b %Y, %H:%M %Z")
|
||||||
|
|
||||||
|
|
||||||
def gap_seconds(since_iso: str | None, ref: datetime | None = None) -> float | None:
|
def gap_seconds(since_iso: str | None, ref: datetime | None = None) -> float | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user