Liking cljdoc? Tell your friends :D

dgknght.tasks.recurrence

Recurring tasks: converting a recurrence rule between a map (the :dgknght.tasks/recurrence spec) and RRULE text, and listing a task's occurrences.

A rule is a map of:

:frequency :secondly, :minutely, :hourly, :daily, :weekly, :monthly or :yearly (required) :interval Positive integer :count Positive integer, the number of occurrences :until java.time.LocalDate, LocalDateTime or Instant, the last possible occurrence (not with :count) :by-day Vector of weekdays, each :su, :mo, :tu, :we, :th, :fr or :sa, or [n weekday] for the nth one, e.g. [-1 :fr] for the last Friday :by-month Vector of months, 1-12 :by-month-day Vector of days of the month, 1-31 or -31 to -1 :by-year-day Vector of days of the year, 1-366 or -366 to -1 :by-week-no Vector of weeks of the year, 1-53 or -53 to -1 :by-hour Vector of hours, 0-23 :by-minute Vector of minutes, 0-59 :by-second Vector of seconds, 0-60 :by-set-pos Vector of positions within the set, 1-366 or -366 to -1 :week-start The weekday weeks start on

Recurring tasks: converting a recurrence rule between a map (the
`:dgknght.tasks/recurrence` spec) and RRULE text, and listing a task's
occurrences.

A rule is a map of:

  :frequency     :secondly, :minutely, :hourly, :daily, :weekly, :monthly
                 or :yearly (required)
  :interval      Positive integer
  :count         Positive integer, the number of occurrences
  :until         java.time.LocalDate, LocalDateTime or Instant, the last
                 possible occurrence (not with :count)
  :by-day        Vector of weekdays, each :su, :mo, :tu, :we, :th, :fr or
                 :sa, or [n weekday] for the nth one, e.g. [-1 :fr] for
                 the last Friday
  :by-month      Vector of months, 1-12
  :by-month-day  Vector of days of the month, 1-31 or -31 to -1
  :by-year-day   Vector of days of the year, 1-366 or -366 to -1
  :by-week-no    Vector of weeks of the year, 1-53 or -53 to -1
  :by-hour       Vector of hours, 0-23
  :by-minute     Vector of minutes, 0-59
  :by-second     Vector of seconds, 0-60
  :by-set-pos    Vector of positions within the set, 1-366 or -366 to -1
  :week-start    The weekday weeks start on
raw docstring

completeclj

(complete {:keys [start due recurrence rdates exdates] :as task}
          recurrence-id
          completed-at)

Completes the occurrence of the task whose original date (its :recurrence-id, as returned by occurrences) is recurrence-id, as Apple Reminders does, at the instant completed-at. Returns a map of:

:completed The completed occurrence as a task of its own: an ordinary, non-recurring task without a :uid, so that saving it creates a new one :recurring The task moved on to its next occurrence. Occurrences before the completed one are passed over: a :count goes down by the number the rule generated, so that the rule ends in the same place, and exdates, rdates and overrides that are left behind are dropped. The next occurrence is the next one the rule generates or, once the rule has no more, the next rdate, in which case the rule is dropped.

When there's no next occurrence (as for a task that doesn't recur), the task itself is completed instead, and returned as :completed with no :recurring.

Throws an ex-info with a :type of ::not-an-occurrence if the task has no occurrence on recurrence-id.

Completes the occurrence of the task whose original date (its
:recurrence-id, as returned by `occurrences`) is `recurrence-id`, as Apple
Reminders does, at the instant `completed-at`. Returns a map of:

  :completed  The completed occurrence as a task of its own: an ordinary,
              non-recurring task without a :uid, so that saving it creates
              a new one
  :recurring  The task moved on to its next occurrence. Occurrences before
              the completed one are passed over: a :count goes down by the
              number the rule generated, so that the rule ends in the same
              place, and exdates, rdates and overrides that are left behind
              are dropped. The next occurrence is the next one the rule
              generates or, once the rule has no more, the next rdate, in
              which case the rule is dropped.

When there's no next occurrence (as for a task that doesn't recur), the
task itself is completed instead, and returned as :completed with no
:recurring.

Throws an ex-info with a :type of ::not-an-occurrence if the task has no
occurrence on `recurrence-id`.
raw docstring

format-ruleclj

(format-rule rule)

Returns the RRULE text for a rule map.

Returns the RRULE text for a rule map.
raw docstring

occurrencesclj

(occurrences {:keys [start due recurrence rdates exdates] :as task} from to)

Returns the occurrences of the task whose original dates (recurrence IDs) are on or after the date from and before the date to, both java.time.LocalDates, in order.

The task's :start, or else its :due, is the first occurrence. Each occurrence is a task map without the recurrence keys, with its own :start and :due (moved by the same amount) and a :recurrence-id of its original date. An occurrence in :overrides is used as it is, as iCalendar replaces the whole occurrence. A task that doesn't recur has at most one occurrence.

Returns the occurrences of the task whose original dates (recurrence IDs)
are on or after the date `from` and before the date `to`, both
java.time.LocalDates, in order.

The task's :start, or else its :due, is the first occurrence. Each
occurrence is a task map without the recurrence keys, with its own :start
and :due (moved by the same amount) and a :recurrence-id of its original
date. An occurrence in :overrides is used as it is, as iCalendar replaces
the whole occurrence. A task that doesn't recur has at most one
occurrence.
raw docstring

parse-ruleclj

(parse-rule s)

Parses RRULE text into a rule map, or returns nil if it has parts the map doesn't model (e.g. RSCALE or an X- part) or can't be parsed, so that the caller can keep the text as it is.

Parses RRULE text into a rule map, or returns nil if it has parts the map
doesn't model (e.g. RSCALE or an X- part) or can't be parsed, so that the
caller can keep the text as it is.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close