Skip to content

Commit f01d916

Browse files
committed
Makes time_zone_database configurable
1 parent bfe967a commit f01d916

5 files changed

Lines changed: 12 additions & 12 deletions

File tree

lib/cocktail/schedule_state.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ defmodule Cocktail.ScheduleState do
3737
%__MODULE__{
3838
recurrence_rules: schedule.recurrence_rules |> Enum.map(&RuleState.new/1),
3939
recurrence_times: recurrence_times_after_current_time,
40-
exception_times: schedule.exception_times |> Enum.uniq() |> Enum.sort(&(Cocktail.Time.compare(&1, &2) in [:lt, :eq])),
40+
exception_times:
41+
schedule.exception_times |> Enum.uniq() |> Enum.sort(&(Cocktail.Time.compare(&1, &2) in [:lt, :eq])),
4142
start_time: schedule.start_time,
4243
current_time: current_time,
4344
duration: schedule.duration

lib/cocktail/time.ex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ defmodule Cocktail.Time do
7777
end
7878
end
7979

80-
8180
defp new_coerced_datetime(year, month, day, hour, minute, second, microsecond, timezone) do
8281
days_in_month_b = :calendar.last_day_of_the_month(year, month)
8382

@@ -340,6 +339,6 @@ defmodule Cocktail.Time do
340339
def parse(_, _), do: {:error, :invalid_format}
341340

342341
defp get_time_zone_datebase do
343-
Application.get_env(:elixir, :time_zone_database, Tzdata.TimeZoneDatabase)
342+
Application.get_env(:elixir, :time_zone_database)
344343
end
345344
end

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ defmodule Cocktail.Mixfile do
8181
{:dialyxir, "~> 1.0", only: [:dev, :test], runtime: false},
8282
{:ex_doc, "~> 0.23", only: :dev, runtime: false},
8383
{:excoveralls, "~> 0.10", only: :test},
84-
{:tzdata, "~> 1.1"}
84+
{:tzdata, "~> 1.1", only: :test}
8585
]
8686
end
8787
end

test/cocktail/monthly_test.exs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ defmodule Cocktail.MonthlyTest do
138138
|> Schedule.add_recurrence_rule(:monthly, interval: 3)
139139

140140
assert first_n_occurrences(schedule, 7) == [
141-
~U[2017-01-02 06:00:00Z],
142-
~U[2017-03-02 06:00:00Z],
143-
~U[2017-04-02 06:00:00Z],
144-
~U[2017-05-02 06:00:00Z],
145-
~U[2017-07-02 06:00:00Z],
146-
~U[2017-09-02 06:00:00Z],
147-
~U[2017-10-02 06:00:00Z]
141+
~Y[2017-01-02 06:00:00 Etc/UTC],
142+
~Y[2017-03-02 06:00:00 Etc/UTC],
143+
~Y[2017-04-02 06:00:00 Etc/UTC],
144+
~Y[2017-05-02 06:00:00 Etc/UTC],
145+
~Y[2017-07-02 06:00:00 Etc/UTC],
146+
~Y[2017-09-02 06:00:00 Etc/UTC],
147+
~Y[2017-10-02 06:00:00 Etc/UTC]
148148
]
149149

150150
assert_icalendar_preserved(schedule)

test/test_helper.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ExUnit.configure(exclude: [pending: true], formatters: [ExUnit.CLIFormatter, ExUnitNotifier])
22
ExUnit.start()
3-
3+
Application.put_env(:elixir, :time_zone_database, Tzdata.TimeZoneDatabase)
44
Code.require_file("test/support/datetime_sigil.ex")

0 commit comments

Comments
 (0)