Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load timezone database from the OS #106

Open
dcastro opened this issue Sep 6, 2023 · 0 comments
Open

Load timezone database from the OS #106

dcastro opened this issue Sep 6, 2023 · 0 comments
Milestone

Comments

@dcastro
Copy link
Member

dcastro commented Sep 6, 2023

Clarification and motivation

At the moment, we're using Data.Time.TZInfo.fromLabel to fetch the timezone rules for some given timezone.

eithTzInfo :: Either UnknownTimeZoneAbbrev TZI.TZInfo
eithTzInfo = case timeRef.trLocationRef of
Nothing -> pure $ TZI.fromLabel sendersTZLabel
Just (TimeZoneRef tzLabel) -> pure $ TZI.fromLabel tzLabel
Just (OffsetRef offset) -> pure $ tzInfoFromOffset offset
Just (TimeZoneAbbreviationRef abbrev) -> pure $ tzInfoFromOffset $ abbrev.tzaiOffsetMinutes
Just (UnknownTimeZoneAbbreviationRef unknownAbbrev) -> Left unknownAbbrev

However, as the haddocks state, this uses the IANA database embedded inside the tzdata package:

image

Timezone rules are constantly getting updated and, unless we constantly upgrade the tzdata dependency to the latest version, eventually we'll be using old timezone rules, leading to wrong conversions.

Instead, we should use the operating system's timezone database, using Data.Time.TZInfo.loadFromSystem.

Note:

  • Let's first check with the SRE team whether the server indeed contains this database, and that it is updated regularly.
  • loadFromSystem will not work on Windows. We should document that the server cannot run on Windows.
    • (we could workaround this by defaulting to using fromLabel on windows, but if there's no need to support windows, then it's not worth doing)
@dcastro dcastro modified the milestones: v1, v1.1 Sep 7, 2023
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

No branches or pull requests

1 participant