Skip to content

Commit

Permalink
Fix tests for new tzdata for America/Montevideo
Browse files Browse the repository at this point in the history
For America/Montevideo the zone abbreviation has been changed in tzdata
from UYST to -02 and UYT to -03. Reflect this in the tests.
  • Loading branch information
lau committed Jun 13, 2018
1 parent 57de32e commit 966b7c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -184,7 +184,7 @@ Montevideo:
{:ok, mvd} = Calendar.DateTime.from_erl {{2014,10,4},{23,44,32}}, "America/Montevideo"
{:ok,
%DateTime{calendar: Calendar.ISO, day: 4, hour: 23, microsecond: {0, 0}, minute: 44, month: 10, second: 32, std_offset: 0,
time_zone: "America/Montevideo", utc_offset: -10800, year: 2014, zone_abbr: "UYT"}}
time_zone: "America/Montevideo", utc_offset: -10800, year: 2014, zone_abbr: "-03"}}
```

A DateTime struct is now assigned to the variable `mvd`. Let's get a DateTime
Expand Down
8 changes: 4 additions & 4 deletions lib/calendar/ambiguous_date_time.ex
Expand Up @@ -29,7 +29,7 @@ defmodule Calendar.AmbiguousDateTime do
## Examples
iex> {:ambiguous, am} = Calendar.DateTime.from_erl({{2014, 3, 9}, {1, 1, 1}}, "America/Montevideo"); am |> Calendar.AmbiguousDateTime.disamb_total_off(-10800)
{:ok, %DateTime{zone_abbr: "UYT", day: 9, hour: 1, minute: 1, month: 3, second: 1, std_offset: 0, time_zone: "America/Montevideo", utc_offset: -10800, year: 2014, microsecond: {0,0}}}
{:ok, %DateTime{zone_abbr: "-03", day: 9, hour: 1, minute: 1, month: 3, second: 1, std_offset: 0, time_zone: "America/Montevideo", utc_offset: -10800, year: 2014, microsecond: {0,0}}}
iex> {:ambiguous, am} = Calendar.DateTime.from_erl({{2014, 3, 9}, {1, 1, 1}}, "America/Montevideo"); am |> Calendar.AmbiguousDateTime.disamb_total_off(0)
{:error, :no_matches}
Expand All @@ -45,10 +45,10 @@ defmodule Calendar.AmbiguousDateTime do
## Examples
We provide a function that returns true if the abbreviation is "UYT"
We provide a function that returns true if the abbreviation is "-03"
iex> {:ambiguous, am} = Calendar.DateTime.from_erl({{2014, 3, 9}, {1, 1, 1}}, "America/Montevideo"); am |> Calendar.AmbiguousDateTime.disamb(fn(dt) -> dt.zone_abbr == "UYT" end)
{:ok, %DateTime{zone_abbr: "UYT", day: 9, hour: 1, minute: 1, month: 3, second: 1, std_offset: 0, time_zone: "America/Montevideo", utc_offset: -10800, year: 2014, microsecond: {0, 0}}}
iex> {:ambiguous, am} = Calendar.DateTime.from_erl({{2014, 3, 9}, {1, 1, 1}}, "America/Montevideo"); am |> Calendar.AmbiguousDateTime.disamb(fn(dt) -> dt.zone_abbr == "-03" end)
{:ok, %DateTime{zone_abbr: "-03", day: 9, hour: 1, minute: 1, month: 3, second: 1, std_offset: 0, time_zone: "America/Montevideo", utc_offset: -10800, year: 2014, microsecond: {0, 0}}}
A function that always returns false
Expand Down
16 changes: 8 additions & 8 deletions lib/calendar/date_time.ex
Expand Up @@ -509,7 +509,7 @@ defmodule Calendar.DateTime do
Example:
iex> from_erl!({{2014, 9, 26}, {17, 10, 20}}, "America/Montevideo")
%DateTime{day: 26, hour: 17, minute: 10, month: 9, second: 20, year: 2014, time_zone: "America/Montevideo", zone_abbr: "UYT", utc_offset: -10800, std_offset: 0}
%DateTime{day: 26, hour: 17, minute: 10, month: 9, second: 20, year: 2014, time_zone: "America/Montevideo", zone_abbr: "-03", utc_offset: -10800, std_offset: 0}
"""
def from_erl!(date_time, time_zone, microsecond \\ {0, 0}) do
{:ok, result} = from_erl(date_time, time_zone, microsecond)
Expand All @@ -534,7 +534,7 @@ defmodule Calendar.DateTime do
iex> from_erl({{2014, 9, 26}, {17, 10, 20}}, "America/Montevideo")
{:ok, %DateTime{day: 26, hour: 17, minute: 10, month: 9, second: 20,
year: 2014, time_zone: "America/Montevideo",
zone_abbr: "UYT",
zone_abbr: "-03",
utc_offset: -10800, std_offset: 0, microsecond: {0, 0}} }
Switching from summer to wintertime in the fall means an ambigous time.
Expand All @@ -543,10 +543,10 @@ defmodule Calendar.DateTime do
{:ambiguous, %Calendar.AmbiguousDateTime{possible_date_times:
[%DateTime{day: 9, hour: 1, minute: 1, month: 3, second: 1,
year: 2014, time_zone: "America/Montevideo",
zone_abbr: "UYST", utc_offset: -10800, std_offset: 3600},
zone_abbr: "-02", utc_offset: -10800, std_offset: 3600},
%DateTime{day: 9, hour: 1, minute: 1, month: 3, second: 1,
year: 2014, time_zone: "America/Montevideo",
zone_abbr: "UYT", utc_offset: -10800, std_offset: 0},
zone_abbr: "-03", utc_offset: -10800, std_offset: 0},
]}
}
Expand All @@ -564,7 +564,7 @@ defmodule Calendar.DateTime do
iex> from_erl({{2014, 9, 26}, {17, 10, 20}}, "America/Montevideo", {987654, 6})
{:ok, %DateTime{day: 26, hour: 17, minute: 10, month: 9, second: 20,
year: 2014, time_zone: "America/Montevideo",
zone_abbr: "UYT",
zone_abbr: "-03",
utc_offset: -10800, std_offset: 0, microsecond: {987654, 6}} }
"""
Expand Down Expand Up @@ -646,13 +646,13 @@ defmodule Calendar.DateTime do
iex> from_erl_total_off({{2014, 9, 26}, {17, 10, 20}}, "America/Montevideo", -10800, 2)
{:ok, %DateTime{day: 26, hour: 17, minute: 10, month: 9, second: 20,
year: 2014, time_zone: "America/Montevideo",
zone_abbr: "UYT",
zone_abbr: "-03",
utc_offset: -10800, std_offset: 0, microsecond: {2, 6}} }
iex> from_erl_total_off({{2014, 3, 9}, {1, 1, 1}}, "America/Montevideo", -7200, 2)
{:ok, %DateTime{day: 9, hour: 1, minute: 1, month: 3, second: 1,
year: 2014, time_zone: "America/Montevideo", microsecond: {2, 6},
zone_abbr: "UYST", utc_offset: -10800, std_offset: 3600}
zone_abbr: "-02", utc_offset: -10800, std_offset: 3600}
}
"""
def from_erl_total_off(erl_dt, timezone, total_off, microsecond\\{0,0}) do
Expand All @@ -674,7 +674,7 @@ defmodule Calendar.DateTime do
iex> from_micro_erl_total_off({{2014, 3, 9}, {1, 1, 1, 2}}, "America/Montevideo", -7200)
{:ok, %DateTime{day: 9, hour: 1, minute: 1, month: 3, second: 1,
year: 2014, time_zone: "America/Montevideo", microsecond: {2, 6},
zone_abbr: "UYST", utc_offset: -10800, std_offset: 3600}
zone_abbr: "-02", utc_offset: -10800, std_offset: 3600}
}
"""
def from_micro_erl_total_off({{year, mon, day}, {hour, min, sec, microsecond}}, timezone, total_off) do
Expand Down

0 comments on commit 966b7c6

Please sign in to comment.