Code Room
Code reviewHardcr-g327
Subject Date arithmeticLevel Senior–Staff~22 minCommon in Code quality & review interviewsIndustries Software development

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.

Talk through your review
Code to reviewpython
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.