serokell / tzbot

Timezone bot for Slack
Mozilla Public License 2.0
7 stars 2 forks source link

Alert user if they use a "winter timezone abbreviation" during summer. #103

Open dcastro opened 1 year ago

dcastro commented 1 year ago

Clarification and motivation

If, in August, a user says "10am WET", it's very likely they meant to say "10am WEST" instead, since no timezone in the world observes the WET offset at that time of the year.

We should tell the user about this, and suggest they edit their message to WEST. Something along the lines of:

No timezone observes the WET offset (UTC +0) on 1 August 2023. Did you mean to say "WEST" instead? If so, please edit your message.

We should do the same for other timezone abbreviation pairs, like PST/PDT, EST/EDT, etc.

Caveats

Unidirectional pairs

The BST offset is observed during summer in Europe/London, Europe/Guernsey, Europe/Isle_of_Man and Europe/Jersey.

According to https://www.timeanddate.com/time/zones/bst, all of these timezones observe GMT during winter, so it's reasonable to suggest the user edits their message to GMT during winter.

However, the opposite is not true. If a user says "GMT" during summer, it's not at all reasonable to suggest they edit their message to "BST". In this case, we should not emit a warning at all.

Year-round offsets

The CET/CEST pair is an odd one (though there may be more like it). During summer, almost all timezones change their offset to CEST, except:

So, should we or should we not tell the user anything if they say "CET" during summer?

I think we should. According to https://www.timeanddate.com/time/zones/cet, there are 31 countries that change CET -> CEST during summer and only 2 that don't, so it's highly likely the user meant to say CEST, though not guaranteed.

We should adjust the message's phrasing accordingly, e.g. instead of saying "No timezones ..." we could say "Most timezones ...".

Implementation

It's currently not clear where/how to obtain the information about how many timezones in the world observe a given timezone abbreviation at a given moment in time.

At a quick glance, the tzdata package seems to have enough information for this: https://hackage.haskell.org/package/tzdata-0.2.20230322.0/docs/src/Data.Time.Zones.DB.html#tzDescriptions

PS: Note that timezone abbreviations with the same offset are NOT equivalent. Both WET and GMT have the offset UTC+0, but they should not be treated similarly.