dillonkearns/elm-ical/1.0.0

Ical.Recurrence

Types for iCal recurrence rules (RFC 5545 Section 3.3.10).

RecurrenceRule is the transparent record returned by Ical.Parser for reading parsed recurrence data. Frequency and DaySpec are also used when building rules for generation via Ical.Generator.Rule.

Parsed rule data

type alias RecurrenceRule =
{ frequency : Frequency
, end : RecurrenceEnd
, byDay : List DaySpec
, byMonthDay : List Int
, byMonth : List Month
, bySetPos : List Int
, byHour : List Int
, byMinute : List Int
, bySecond : List Int
, byYearDay : List Int
, byWeekNo : List Int
}

A parsed recurrence rule (RRULE). This is the transparent record returned by Ical.Parser for reading parsed rule data. For constructing rules for generation, use Ical.Generator.Rule and its builder functions.

{ frequency = Weekly { every = 1, weekStart = Time.Mon }
, end = Forever
, byDay = [ every Time.Mon ]
, byMonthDay = []
, byMonth = []
, bySetPos = []
, byHour = []
, byMinute = []
, bySecond = []
, byYearDay = []
, byWeekNo = []
}
  • byDay — which days of the week (with optional ordinals for monthly/yearly).
  • byMonthDay — which days of the month (1–31, or -31 to -1 from month end).
  • byMonth — which months.
  • bySetPos — pick the Nth result from the set produced by the other by* parts within each frequency period. Positive counts from the start, negative from the end. For example, BYDAY=MO,TU,WE,TH,FR with bySetPos = [ -1 ] means "the last weekday" of each period.
  • byHour — which hours (0–23).
  • byMinute — which minutes (0–59).
  • bySecond — which seconds (0–60, 60 for leap second).
  • byYearDay — which days of the year (1–366, or -366 to -1 from year end).
  • byWeekNo — which ISO week numbers (1–53, or -53 to -1 from year end).
= Forever
| Count Int
| UntilDate Date
| UntilDateTime Posix

When the recurrence stops. Count and Until* are mutually exclusive per RFC 5545 Section 3.3.10.

Shared types

= Secondly { every : Int }
| Minutely { every : Int }
| Hourly { every : Int }
| Daily { every : Int }
| Weekly
{ every : Int
, weekStart : Weekday
}
| Monthly { every : Int }
| Yearly { every : Int }

How often the event recurs. Each variant carries its own configuration:

  • every — the interval between occurrences (e.g. every = 2 with Weekly means every other week). Must be at least 1.
  • weekStart — which day begins the week (only meaningful for Weekly).
type DaySpec

A day-of-week specifier for recurrence rules.

Create one with every, nth, or the convenience helpers like second and last.

-- every Monday
every Time.Mon


-- the 2nd Sunday of the month
second Time.Sun


-- the last Friday
last Time.Fri

Positive ordinals count from the start of the period. Negative ordinals count from the end. nth accepts -53..-1 and 1..53, matching the RFC grammar for numeric BYDAY values.

every : Weekday -> DaySpec

Match every instance of the given weekday.

nth : Int -> Weekday -> Maybe DaySpec

Match the nth instance of a weekday.

Positive values count from the start, negative values count from the end, and 0 is invalid.

nth 20 Time.Mon


nth -1 Time.Fri
weekday : DaySpec -> Weekday

Extract the weekday from a DaySpec.

ordinal : DaySpec -> Maybe Int

Extract the ordinal from a DaySpec, if present.

first : Weekday -> DaySpec

The 1st instance of a weekday.

second : Weekday -> DaySpec

The 2nd instance of a weekday.

third : Weekday -> DaySpec

The 3rd instance of a weekday.

fourth : Weekday -> DaySpec

The 4th instance of a weekday.

fifth : Weekday -> DaySpec

The 5th instance of a weekday.

last : Weekday -> DaySpec

The last instance of a weekday.

secondToLast : Weekday -> DaySpec

The 2nd-to-last instance of a weekday.

thirdToLast : Weekday -> DaySpec

The 3rd-to-last instance of a weekday.

fourthToLast : Weekday -> DaySpec

The 4th-to-last instance of a weekday.

fifthToLast : Weekday -> DaySpec

The 5th-to-last instance of a weekday.