Code Room
Code reviewHard
Question
Review this Python code that converts a logged local timestamp to UTC for storage (drivers log in their local zone).
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
from datetime import datetimefrom zoneinfo import ZoneInfo def to_utc(local_str, tzname): # local_str like '2026-11-01 01:30:00', tzname like 'America/New_York' naive = datetime.strptime(local_str, '%Y-%m-%d %H:%M:%S') return naive.replace(tzinfo=ZoneInfo(tzname)).astimezone(ZoneInfo('UTC'))Run or narrate your approach, then ask the coach.