A port of the Ruby ice_cube gem to Haskell.
ice-cube has a very small API. The date type it uses comes from the Data.Dates
package.
importData.DatesimportIceCube (mkSchedule, occurrences, Rule(..))Use mkSchedule to create your schedule. mkSchedule takes a start date, an
optional end date and a list of recurrence rules.
-- Create a schedule for the 15 of every month,-- starting on Jan 1st 2017 and ending on Jan 1st 2018let start =DateTime201711000
end =DateTime201811000
schedule = mkSchedule start (Just end) [DayOfMonth15]
-- Create a schedule for the Fridays in February,-- starting on Jan 1st 2017 and continuing foreverlet start =DateTime201711000
schedule = mkSchedule start Nothing [DayOfWeekFriday, MonthOfYear2]You can pass any number of rules to a schedule to create more complex recurrence patterns.
-- Every two weeks on Friday
[WeeklyInterval2, DayOfWeekFriday]
-- Every other year on the 12th of March
[YearlyInterval2, MonthOfYear3, DayOfMonth12]
-- Every day[]See the documentation for an exhaustive list of rules.
To get the dates for a schedule, use occurrences. If the schedule has no end
date, the returned list of dates will be infinite.
let start =DateTime201711000-- January 1st 2017
end =DateTime201811000-- January 1st 2018
schedule = mkSchedule start (Just end) [DayOfMonth15]
first_date =take1$ occurrences schedule