Skip to content

calendar: avoid ambiguous timezone inference from offsets#492

Open
RaphaelRUzan wants to merge 1 commit intosteipete:mainfrom
RaphaelRUzan:fix-calendar-timezone-inference
Open

calendar: avoid ambiguous timezone inference from offsets#492
RaphaelRUzan wants to merge 1 commit intosteipete:mainfrom
RaphaelRUzan:fix-calendar-timezone-inference

Conversation

@RaphaelRUzan
Copy link
Copy Markdown

Summary

Avoid ambiguous regional timezone inference from offset-only RFC3339 inputs.

This changes calendar event timezone extraction to use fixed-offset Etc/GMT±N zones instead of guessing named regions like America/Phoenix or America/Los_Angeles from a numeric offset alone.

Why

Offsets like -07:00 are ambiguous at a given instant and can match multiple regional IANA zones. The previous logic returned the first matching US timezone, which could mislabel Pacific events as America/Phoenix.

Using a fixed-offset timezone is less pretty, but safer and non-deceptive when the input does not carry a true named timezone.

Changes

  • remove ambiguous US region guessing from extractTimezone()
  • keep UTC for zero offset
  • keep Etc/GMT±N fallback for whole-hour offsets
  • update tests accordingly

Tests

Ran:

go test ./internal/cmd -run 'TestExtractTimezone|TestCalendarCreateCmd_RecurringIncludesTimezone|TestCalendarUpdateCmd_RecurrenceFillsMissingTimezone'

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant