Liking cljdoc? Tell your friends :D
Clojure only.

urpx.holidays

Derive a holiday-date predicate from a rate plan's embedded urpx:HolidayCalendar.

URPX rate plans may embed a HolidayCalendar at :urpx/hasRatePlanVersion → :urpx/hasPlanElements → :urpx/hasHolidayCalendar listing each Holiday with a urpx:holidayName plus either:

  • urpx:holidayDate — literal xsd:date for one specific instance, OR
  • urpx:holidayRule — free-form string like 'Third Monday in February' or 'January 1 (legally observed)'.

derive-predicate returns a (java.time.LocalDate -> bool) predicate, or nil when the plan has no embedded calendar. The predicate covers any year on demand; per-year date sets are computed once and cached internally so driving price-schedule across thousands of timestamps doesn't repeat work.

Recognized urpx:holidayRule patterns:

  • 'First|Second|Third|Fourth|Fifth <Weekday> in <Month>'
  • 'Last <Weekday> in <Month>'
  • '<Month> <Day>' — observed on the actual date
  • '<Month> <Day> (legally observed)' — observed on the nearest weekday when the actual date falls on a weekend (Sat → Fri, Sun → Mon)

When a Holiday carries an explicit urpx:observanceRule (Ref to one of urpx:actualDateObservance / urpx:nearestWeekdayObservance / urpx:mondayIfWeekendObservance / urpx:fridayIfWeekendObservance) it overrides the implicit observance derived from the rule string.

Unrecognized rules throw ex-info — pass an explicit :holiday? predicate in urpx.price/resolve-prices opts to override the derived calendar.

Derive a holiday-date predicate from a rate plan's embedded
urpx:HolidayCalendar.

URPX rate plans may embed a HolidayCalendar at
  :urpx/hasRatePlanVersion → :urpx/hasPlanElements → :urpx/hasHolidayCalendar
listing each Holiday with a urpx:holidayName plus either:
  - urpx:holidayDate    — literal xsd:date for one specific instance, OR
  - urpx:holidayRule    — free-form string like 'Third Monday in February'
                          or 'January 1 (legally observed)'.

`derive-predicate` returns a `(java.time.LocalDate -> bool)` predicate, or
nil when the plan has no embedded calendar. The predicate covers any year
on demand; per-year date sets are computed once and cached internally so
driving `price-schedule` across thousands of timestamps doesn't repeat work.

Recognized urpx:holidayRule patterns:
  - 'First|Second|Third|Fourth|Fifth <Weekday> in <Month>'
  - 'Last <Weekday> in <Month>'
  - '<Month> <Day>'                       — observed on the actual date
  - '<Month> <Day> (legally observed)'    — observed on the nearest weekday
                                            when the actual date falls on
                                            a weekend (Sat → Fri, Sun → Mon)

When a Holiday carries an explicit urpx:observanceRule (Ref to one of
urpx:actualDateObservance / urpx:nearestWeekdayObservance /
urpx:mondayIfWeekendObservance / urpx:fridayIfWeekendObservance) it
overrides the implicit observance derived from the rule string.

Unrecognized rules throw ex-info — pass an explicit `:holiday?` predicate
in `urpx.price/resolve-prices` opts to override the derived calendar.
raw docstring

derive-predicateclj

(derive-predicate plan)

Return a (LocalDate -> boolean) predicate computed from plan's embedded urpx:HolidayCalendar, or nil when the plan has no calendar.

The predicate computes the holiday set for any year on demand; results are cached internally so reusing the predicate across many dates is cheap. Throws ex-info if any Holiday in the calendar carries an unparseable urpx:holidayRule.

Return a `(LocalDate -> boolean)` predicate computed from `plan`'s
embedded urpx:HolidayCalendar, or nil when the plan has no calendar.

The predicate computes the holiday set for any year on demand; results
are cached internally so reusing the predicate across many dates is
cheap. Throws ex-info if any Holiday in the calendar carries an
unparseable urpx:holidayRule.
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