The posixtimezones module implements handling of the system timezone files on posix systems. It's not available on non-posix systems.
Usage
import timezones, timezones/posixtimezones # Load a timezone from the systems timezone dir let zone1 = loadPosixTz("Europe/Stockholm") # Load a timezone with an absolute path to the file let zone2 = loadPosixTz("/path/to/timezone/file") # Load all available timezones from the systems timezone dir let db = loadPosixTzDb() # Timezones can now be loaded from the db instead of from the file system let zone3 = db.tz("Europe/Stockholm")
Types
TzFileParsingError = object of ValueError
- Exception which is raised when parsing a posix timezone file fails.
Procs
proc loadPosixTz(path: string): Timezone {...}{.raises: [IOError, TzFileParsingError], tags: [ ReadEnvEffect, ReadIOEffect, ReadDirEffect].}
-
Load a timezone from a posix timezone file.
If path is relative it's interpreted as relative to the system timezone dir, meaning that e.g loadPosixTz"Europe/Stockholm" works. The timezone dir is "/usr/share/zoneinfo/" by default, but can be overriden by setting the TZDIR environment variable.
proc loadPosixTzInfo(path: string): TimezoneInfo {...}{. raises: [IOError, TzFileParsingError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect].}
-
Load a timezone and related metadata from a posix timezone file.
The metadata is loaded from the file zone1970.tab, which is expected to exist in the system timezone dir.
The path argument must be a relative path, and will be interpreted as relative to the system timezone dir. The timezone dir is "/usr/share/zoneinfo/" by default, but can be overriden by setting the TZDIR environment variable.
proc loadPosixTzDb(dir = ""): timezones.TimezoneDb {...}{. raises: [IOError, TzFileParsingError], tags: [ReadEnvEffect, ReadDirEffect, ReadIOEffect].}
-
Load all available timezones and metadata from dir.
If dir is the empty string, the system timezone dir will be used.
The version field of the returned TimezoneDb will be set to the empty string, because there's no reliable way extract the version from a timezone dir.