diff --git a/CHANGELOG.md b/CHANGELOG.md index 84f26ce..6d83957 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased][] +## [0.8.1][] - 2018-02-17 +### Fixed +- Allow backwards compatible parsing of BYTIME rule for existing schedules generated using cocktail pre-0.8. + ## [0.8.0][] - 2018-02-17 ### Breaking - The `BYTIME` option of `RRULE`s in the iCalendar output is now `X-BYTIME` to better follow the standard's extensions policy @@ -73,7 +77,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## 0.0.1 - 2017-09-08 ### Initial release -[Unreleased]: https://github.com/peek-travel/cocktail/compare/0.8.0...HEAD +[Unreleased]: https://github.com/peek-travel/cocktail/compare/0.8.1...HEAD +[0.8.1]: https://github.com/peek-travel/cocktail/compare/0.8.0...0.8.1 [0.8.0]: https://github.com/peek-travel/cocktail/compare/0.7.0...0.8.0 [0.7.0]: https://github.com/peek-travel/cocktail/compare/0.6.0...0.7.0 [0.6.0]: https://github.com/peek-travel/cocktail/compare/0.5.3...0.6.0 diff --git a/lib/cocktail/parser/i_calendar.ex b/lib/cocktail/parser/i_calendar.ex index 90a6699..4563cf2 100644 --- a/lib/cocktail/parser/i_calendar.ex +++ b/lib/cocktail/parser/i_calendar.ex @@ -183,6 +183,9 @@ defmodule Cocktail.Parser.ICalendar do end end + # backwards compatible parsing for schedules generated pre-0.8 + defp parse_rrule_option("BYTIME=" <> times_string), do: parse_rrule_option("X-BYTIME=" <> times_string) + defp parse_rrule_option("X-BYTIME=" <> times_string) do with {:ok, times} <- parse_times_string(times_string) do {:ok, {:times, times |> Enum.reverse()}} diff --git a/mix.exs b/mix.exs index 516c7d1..408516b 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Cocktail.Mixfile do use Mix.Project - @version "0.8.0" + @version "0.8.1" def project do [ diff --git a/test/cocktail/parser/i_calendar_test.exs b/test/cocktail/parser/i_calendar_test.exs index 75d35db..343bbd3 100644 --- a/test/cocktail/parser/i_calendar_test.exs +++ b/test/cocktail/parser/i_calendar_test.exs @@ -2,7 +2,7 @@ defmodule Cocktail.Parser.ICalendarTest do use ExUnit.Case alias Cocktail.Rule - alias Cocktail.Validation.{Interval, Day, HourOfDay, MinuteOfHour, SecondOfMinute} + alias Cocktail.Validation.{Interval, Day, HourOfDay, MinuteOfHour, SecondOfMinute, TimeOfDay} import Cocktail.Parser.ICalendar import Cocktail.TestSupport.DateTimeSigil @@ -95,6 +95,17 @@ defmodule Cocktail.Parser.ICalendarTest do assert rule.validations[:second_of_minute] == %SecondOfMinute{seconds: [0, 30]} end + test "parse a pre-0.8 schedule with a BYTIME option to an rrule" do + schedule_string = """ + DTSTART:20170810T090000 + RRULE:FREQ=DAILY;BYTIME=090000,100000,110000 + """ + + assert {:ok, schedule} = parse(schedule_string) + assert [%Rule{} = rule] = schedule.recurrence_rules + assert rule.validations[:time_of_day] == %TimeOfDay{times: [{9, 0, 0}, {10, 0, 0}, {11, 0, 0}]} + end + ########## # Errors # ##########