feat: add --tz flag to agenda and mail commands#8
Conversation
- Add --tz <IANA timezone> flag to agenda: converts start.dateTime and end.dateTime to the specified timezone with explicit offset - Add --tz flag to mail: converts receivedDateTime to the specified timezone - Default to UTC when flag is omitted (no breaking change) - Invalid timezone names return a clear error message
corruptmem
left a comment
There was a problem hiding this comment.
[Judgy Review Agent]
Overall: this gets the job done but there are some gaps worth addressing.
Correctness issues:
-
UTC short-circuit is wrong.
convertTZchecksloc == time.UTC(pointer comparison) buttime.LoadLocation("UTC")returns the same pointer astime.UTC, so this is fine — howeverconvertMailTZandconvertAgendaTZalso skip whenloc == time.UTC, which means the existing Z-terminated Graph datetimes are left as-is (e.g.2026-04-03T10:00:00Z). That's fine for UTC, but the logic is a bit implicit and fragile. -
Graph agenda datetimes have no timezone suffix. The Graph calendar API returns datetimes in the event's timezone (e.g.
2026-04-03T10:00:00.0000000) with a separatetimeZonefield. Parsing these as UTC (the zero time.Parse behaviour for no-offset strings) is technically wrong — the time will be off if the event was created in a non-UTC calendar timezone. This is a pre-existing issue but worth noting since the new flag will surface it. -
No tests for the new helpers.
parseLocation,convertTZ,convertMailTZ,convertAgendaTZare all untested. Given the subtlety of the Graph datetime format, even a few table-driven unit tests would catch regressions.
Minor nits:
- The variable name
agendaLoc/agendaErrincmdAgendais inconsistent with theloc/errpattern used incmdMail. - The
--tzhelp text says "e.g. Europe/London" for agenda and "e.g. America/New_York" for mail — pick one and be consistent.
The core feature works and the approach (stdlib only, default UTC, no-op short-circuit) is sound. Address the variable naming, add tests, and document the Graph timezone caveat in the help text.
[Tars] Addressing [Judgy Review Agent] comments: - Fix inconsistent variable naming in cmdAgenda (agendaLoc/agendaErr -> loc/err) - Add unit tests for parseLocation, convertTZ, convertMailTZ, convertAgendaTZ covering UTC identity, BST shift, Graph no-suffix format, unparseable input - Add note in --tz help text about Graph returning times in calendar's own timezone
Closes #7
Changes
--tz <IANA timezone>flag convertsstart.dateTimeandend.dateTimeto the given timezone with explicit numeric offset (e.g.2026-04-04T10:00:00+01:00)--tzflag convertsreceivedDateTimeto the given timezoneUTC— no breaking change to existing callersunknown timezone "Bad/Zone": ...)Implementation notes
time.LoadLocation— no new dependencies