timex v3.5.0 Timex.Timezone.Local View Source
This module is responsible for determining the timezone configuration of the local machine. It determines this from a number of sources, depending on platform, but the order of precedence is as follows:
ALL:
- TZ environment variable. Ignored if nil/empty
OSX:
- /etc/localtime
- systemsetup -gettimezone (if admin rights are present)
UNIX:
- /etc/timezone
- /etc/sysconfig/clock
- /etc/conf.d/clock
- /etc/localtime
- /usr/local/etc/localtime
Windows:
- SYSTEM registry for the currently configured TimeZoneInformation
Each location is tried, and if an error is encountered, the next is attempted, until either a successful lookup is performed, or we run out of locations to check.
Link to this section Summary
Functions
Looks up the local timezone configuration. Returns the name of a timezone in the Olson database
Given a binary representing the data from a tzfile (not the source version), parses out the timezone for the curent date/time in UTC
Same as parse_tzfile/1
, but takes a reference date (in gregorian seconds). The reference
date will be used to locate the timezone period for the local timezone which applies to that date
Link to this section Types
gregorian_seconds()
View Source
gregorian_seconds() :: non_neg_integer()
gregorian_seconds() :: non_neg_integer()
Link to this section Functions
lookup() View Source
Looks up the local timezone configuration. Returns the name of a timezone in the Olson database.
If no reference time is provided (in gregorian seconds), the current time in UTC will be used. If one is provided, the reference time will be used to find the local timezone for that reference time, if it exists.
lookup(secs)
View Source
lookup(gregorian_seconds()) :: String.t() | {:error, term()}
lookup(gregorian_seconds()) :: String.t() | {:error, term()}
parse_tzfile(tzdata) View Source
Given a binary representing the data from a tzfile (not the source version), parses out the timezone for the curent date/time in UTC.
parse_tzfile(tzdata, reference_date)
View Source
parse_tzfile(binary(), gregorian_seconds()) ::
{:ok, String.t()} | {:error, term()}
parse_tzfile(binary(), gregorian_seconds()) :: {:ok, String.t()} | {:error, term()}
Same as parse_tzfile/1
, but takes a reference date (in gregorian seconds). The reference
date will be used to locate the timezone period for the local timezone which applies to that date.