Packages
tz_extra
0.2.0
0.45.0
0.44.0
0.43.0
0.42.0
0.41.0
0.40.0
0.39.0
0.38.0
0.37.0
0.36.0
0.35.0
0.34.0
0.33.0
0.32.0
0.31.0
0.30.0
0.29.0
0.28.0
0.27.0
0.26.0
0.25.0
0.24.0
0.23.0
0.22.1
0.22.0
0.21.1
0.21.0
0.20.1
0.20.0
0.17.0
0.16.7
0.16.6
0.16.5
0.16.3
0.16.2
0.16.1
0.16.0
0.15.1
0.15.0
0.8.0
0.7.0
0.6.0
0.5.0
0.4.0
0.3.0
0.2.0
0.1.0
Time zone-related utilities
Current section
Files
Jump to
Current section
Files
README.md
# TzExtra
`tz_extra` provides a few utilities to work with time zones.
### `TzExtra.time_zones/0`
Returns a list of time zones with useful data such as
* the coordinates of the location
* the country where the time zone is observed
* the UTC and DST offsets
#### Example
```
iex> TzExtra.time_zones() |> Enum.at(200)
```
```
%{
coordinates: "+513030-0000731",
country: %{code: "JE", name: "Jersey"},
dst_offset: 3600,
name: "Europe/London",
pretty_dst_offset: "+01:00",
pretty_utc_offset: "+00:00",
utc_offset: 0
}
```
If a time zone is observed in multiple countries, the time zone data will be repeated for each country. For example,
Crimea has been a subject of a territorial dispute between Ukraine and Russia:
```
iex> TzExtra.time_zones() |> Enum.filter(& &1.name == "Europe/Simferopol")
```
```
[
%{
coordinates: "+4457+03406",
country: %{code: "RU", name: "Russia"},
dst_offset: 10800,
name: "Europe/Simferopol",
pretty_dst_offset: "+03:00",
pretty_utc_offset: "+03:00",
utc_offset: 10800
},
%{
coordinates: "+4457+03406",
country: %{code: "UA", name: "Ukraine"},
dst_offset: 10800,
name: "Europe/Simferopol",
pretty_dst_offset: "+03:00",
pretty_utc_offset: "+03:00",
utc_offset: 10800
}
]
```
### `TzExtra.countries/0`
```
iex> TzExtra.countries() |> Enum.take(5)
```
```
[
%{code: "AF", name: "Afghanistan"},
%{code: "AL", name: "Albania"},
%{code: "DZ", name: "Algeria"},
%{code: "AD", name: "Andorra"},
%{code: "AO", name: "Angola"}
]
```
## Installation
Add `tz_extra` for Elixir as a dependency in your `mix.exs` file:
```elixir
def deps do
[
{:tz_extra, "~> 0.2.0"}
]
end
```
## HexDocs
HexDocs documentation can be found at [https://hexdocs.pm/tz_extra](https://hexdocs.pm/tz_extra).