Skip to content

Load timezone database from the OS #106

Open
@dcastro

Description

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)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions