from datetime import datetime from zoneinfo import ZoneInfo _tz = ZoneInfo("Asia/Taipei") def configure_timezone(tz_name: str) -> None: """Update the application timezone. Called on startup and when settings change.""" global _tz try: _tz = ZoneInfo(tz_name) except Exception: _tz = ZoneInfo("Asia/Taipei") def now_tw() -> datetime: """Return current time in the configured timezone as a naive datetime.""" return datetime.now(tz=_tz).replace(tzinfo=None)