Local time detection, timezone conversion
Detecting user's local time at session start
date '+%Y-%m-%d %H:%M:%S %Z %z'
This gives the exact time, timezone and UTC offset from the system clock.
datetime with zoneinfofrom datetime import datetime
from zoneinfo import ZoneInfo
import subprocess
# Determine timezone from system
result = subprocess.run(['date', '+%z'], capture_output=True, text=True)
offset = result.stdout.strip() # e.g. "+0800"
# Or use timezone directly
local_tz = ZoneInfo('Asia/Makassar') # WITA, UTC+8
# Convert from another timezone
event_time = datetime.fromisoformat('2026-02-16T13:30:00+01:00') # CET
local_time = event_time.astimezone(local_tz)
print(local_time.strftime('%H:%M %Z')) # -> 20:30 WITA
Asia/Makassardaily-briefing -- displays event timesshow-today -- deadlines