Timex.Timezone

This module is used for looking up the timezone information for a given point in time, in the desired zone. Timezones are dependent not only on locale, but the date and time for which you are querying. For instance, the timezone offset from UTC for Europe/Moscow is different for March 3rd of 2015, than it was in 2013. These differences are important, and as such, all functions in this module are date/time sensitive, and where omitted, the current date/time are assumed.

In addition to lookups, this module also does conversion of datetimes from one timezone period to another, and determining the difference between a date in one timezone period and the same date/time in another timezone period.

Summary

convert(date, tz)

Convert a date to the given timezone (either TimezoneInfo or a timezone name)

diff(datetime, timezoneinfo)

Determine what offset is required to convert a date into a target timezone

exists?(zone)

Determines if a given zone name exists

get(tz, for \\ Timex.Date.now())

Gets timezone info for a given zone name and date. The date provided can either be an Erlang datetime tuple, or a DateTime struct, and if one is not provided, then the current date and time is returned

local()

Gets the local timezone configuration for the current date and time

local(date)

Gets the local timezone configuration for the provided date and time. The provided date and time can either be an Erlang datetime tuple, or a DateTime struct

Functions

convert(date, tz)

Specs:

Convert a date to the given timezone (either TimezoneInfo or a timezone name)

diff(datetime, timezoneinfo)

Specs:

Determine what offset is required to convert a date into a target timezone

exists?(zone)

Specs:

Determines if a given zone name exists

get(tz, for \\ Timex.Date.now())

Specs:

  • get(String.t, Timex.Date.datetime | %Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term} | nil) :: %Timex.TimezoneInfo{abbreviation: term, from: term, full_name: term, offset_std: term, offset_utc: term, until: term} | {:error, String.t}

Gets timezone info for a given zone name and date. The date provided can either be an Erlang datetime tuple, or a DateTime struct, and if one is not provided, then the current date and time is returned.

local()

Specs:

  • local :: %Timex.TimezoneInfo{abbreviation: term, from: term, full_name: term, offset_std: term, offset_utc: term, until: term}

Gets the local timezone configuration for the current date and time.

local(date)

Specs:

  • local(Timex.Date.datetime | %Timex.DateTime{calendar: term, day: term, hour: term, minute: term, month: term, ms: term, second: term, timezone: term, year: term}) :: %Timex.TimezoneInfo{abbreviation: term, from: term, full_name: term, offset_std: term, offset_utc: term, until: term}

Gets the local timezone configuration for the provided date and time. The provided date and time can either be an Erlang datetime tuple, or a DateTime struct.