View Source Zoneinfo (zoneinfo v0.1.8)

Elixir time zone support for your OS-supplied time zone database

Tell Elixir to use this as the default time zone database by running:

Calendar.put_time_zone_database(Zoneinfo.TimeZoneDatabase)

Time zone data is loaded from the path returned by tzpath/0. The default is to use /usr/share/zoneinfo, but that may be changed by setting the $TZDIR environment or adding the following to your project's config.exs:

config :zoneinfo, tzpath: "/custom/location"

Call time_zones/0 to get the list of supported time zones.

Summary

Functions

Return Zoneinfo metadata on a time zone

Return all known time zones

Return the path to the time zone files

Return whether a time zone is valid

Functions

@spec get_metadata(String.t()) :: {:ok, Zoneinfo.Meta.t()} | {:error, atom()}

Return Zoneinfo metadata on a time zone

The returned metadata is limited to what's available in the source TZif data file for the time zone. It's mostly useful for verifying that time zone information is available for dates used in your application. Note that proper time zone calculations depend on many things and it's possible that they'll work outside of the returned ranged. However, it's also possible that a time zone database was built and then a law changed which invalidates a record.

@spec time_zones() :: [String.t()]

Return all known time zones

This function scans the path returned by tzpath/0 for all time zones and performs a basic check on each file. It may not be fast. It will not return the aliases that zoneinfo uses for backwards compatibility even though they may still work.

@spec tzpath() :: binary()

Return the path to the time zone files

Link to this function

valid_time_zone?(time_zone)

View Source
@spec valid_time_zone?(String.t()) :: boolean()

Return whether a time zone is valid