Packages
tzdata
0.5.3
1.1.4
1.1.3
1.1.2
1.1.1
1.1.0
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-rc.1
1.0.0-rc.0
0.5.22
0.5.21
0.5.20
0.5.19
0.5.18
0.5.17
0.5.16
0.5.15
0.5.14
0.5.13
0.5.12
0.5.11
0.5.10
0.5.9
0.5.8
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.1.201805
0.1.201605
0.1.201603
0.1.201601
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.2
0.0.1
Tzdata is a parser and library for the tz database.
Current section
Files
Jump to
Current section
Files
lib/tzdata/table_data.ex
defmodule Tzdata.TableData do
@moduledoc false
# @moduledoc """
# Provides data about which timezones to use for which area. This is based
# on the information in the zone1970.tab part of the IANA tz database.
#
# The tz database contains a lot of legacy timezones that are not needed for most users.
#
# The database file says:
# > This table is intended as an aid for users, to help
# > them select time zone data entries appropriate for their practical needs.
# > It is not intended to take or endorse any position on legal or territorial claims.
# """
#
# file_read = Tzdata.TableParser.read_file |> Enum.to_list
#
# timezones = Enum.map(file_read, &(&1["timezone"]))
#
# @doc """
# Returns a list of all timezones found in the zone1970.tab file
# """
# def timezones do
# unquote(Macro.escape(timezones))
# end
#
# country_codes = file_read
# |> Enum.flat_map(&(&1["country_codes"]))
# |> Enum.uniq
# |> Enum.sort
#
# @doc """
# Returns a list of all country_codes found in the zone1970.tab file
# """
# def country_codes do
# unquote(Macro.escape(
# country_codes
# ))
# end
#
# keyword_dict_by_country_codes = file_read |> Enum.flat_map(fn entry ->
# Enum.map(entry["country_codes"], &({&1|>String.to_atom, entry}))
# end)
#
# @doc """
# Provides entries with timezones that are in use in the country that
# corresponds to the `country_code` argument.
# """
# Enum.each country_codes, fn (country_code) ->
# def for_country_code(unquote(country_code)) do
# unquote(Macro.escape(
# Keyword.get_values keyword_dict_by_country_codes,
# String.to_atom(country_code)
# ))
# end
# end
# def for_country_code(_), do: :country_code_not_found
#
# @doc """
# Provides the entry for the `timezone` given as argument.
# """
# Enum.each timezones, fn (timezone) ->
# def for_timezone(unquote(timezone)) do
# unquote(Macro.escape(
# Enum.find(file_read, fn(elem) -> elem["timezone"] == timezone end )
# ))
# end
# end
# def for_timezone(_), do: :timezone_not_found
end