Skip to content

Commit

Permalink
Fix bug #24
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuprog committed Dec 9, 2023
1 parent e18d1b0 commit 43df7b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/tz/time_zone_database.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ defmodule Tz.TimeZoneDatabase do
[rule1, rule2] = Tz.OngoingChangingRulesProvider.rules(rule_name)

rule_records = Tz.IanaFileParser.denormalized_rule_data([
Tz.IanaFileParser.change_rule_year(rule2, year - 1),
Tz.IanaFileParser.change_rule_year(rule1, year - 1),
Tz.IanaFileParser.change_rule_year(rule2, year),
Tz.IanaFileParser.change_rule_year(rule1, year)
Expand Down
9 changes: 7 additions & 2 deletions test/time_zone_database_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ defmodule TimeZoneDatabaseTest do
zoned_date_time = date_time_utc |> DateTime.shift_zone!(time_zone, Tz.TimeZoneDatabase)
# #DateTime<2030-01-01 00:00:00+13:45 +1345 Pacific/Chatham>

naive = DateTime.to_naive(zoned_date_time)
naive_datetime = DateTime.to_naive(zoned_date_time)
# ~N[2030-01-01 00:00:00]

assert zoned_date_time == DateTime.from_naive!(naive, time_zone, Tz.TimeZoneDatabase)
assert zoned_date_time == DateTime.from_naive!(naive_datetime, time_zone, Tz.TimeZoneDatabase)

naive_datetime = NaiveDateTime.from_iso8601!("2030-01-01T00:00:00")
datetime = DateTime.from_naive!(naive_datetime, "Europe/Lisbon", Tz.TimeZoneDatabase)

assert DateTime.to_iso8601(datetime) == "2030-01-01T00:00:00+00:00"
end
end

0 comments on commit 43df7b8

Please sign in to comment.