Copyright | (C) 2014 Mihaly Barasz |
---|---|
License | Apache-2.0, see LICENSE |
Maintainer | Mihaly Barasz <klao@nilcons.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- loadTZFromFile :: FilePath -> IO TZ
- loadSystemTZ :: String -> IO TZ
- pathForSystemTZ :: String -> IO FilePath
- loadLocalTZ :: IO TZ
- loadTZFromDB :: String -> IO TZ
- olsonGet :: Get TZ
- parseOlson :: ByteString -> TZ
Various ways of loading TZ
loadTZFromFile :: FilePath -> IO TZ Source #
Reads and parses a time zone information file (in tzfile(5)
aka. Olson file format) and returns the corresponding TZ data
structure.
loadSystemTZ :: String -> IO TZ Source #
Looks for the time zone file in the system timezone directory, which is
/usr/share/zoneinfo
, or if the TZDIR
environment variable is
set, then there.
Note, this is unlikely to work on non-posix systems (e.g.,
Windows), use loadTZFromDB
or loadTZFromFile
instead.
pathForSystemTZ :: String -> IO FilePath Source #
Return the path for a time zone file in the system time zone directory.
The system directory is specified by the TZDIR
environment variable,
or /usr/share/zoneinfo
if it's not set.
loadLocalTZ :: IO TZ Source #
Returns the local TZ
based on the TZ
and TZDIR
environment variables.
See tzset(3)
for details, but basically:
- If
TZ
environment variable is unset, weloadTZFromFile "/etc/localtime"
. - If
TZ
is set, but empty, weloadSystemTZ "UTC"
. - Otherwise, we just
loadSystemTZ
it.
Note, this means we don't support POSIX-style TZ
variables (like
"EST5EDT"
), only those that are explicitly present in the time
zone database.
loadTZFromDB :: String -> IO TZ Source #
Reads the corresponding file from the time zone database shipped with this package.
Parsing Olson data
parseOlson :: ByteString -> TZ Source #