clj-duckling.dims.time.pred
compose
(compose pred)
(compose pred1' pred2')
(compose pred1 pred2 & more)
Compose several predicates - can see this as intersection
cycle
(cycle grain)
A sequence of each year, or month, or week, etc.
Used for 'this year', 'next month', 'last week'..
day-of-month
(day-of-month dom)
day-of-week
(day-of-week dow)
fn&
macro
(fn& grain args & forms)
hour
(hour h twelve-hour-clock?)
intervals
(intervals pred-from pred-to inclusive-to?)
Builds a sequence of intervals, each starting at the start of pred-from
and ending at the start (inclusive-to? false) or end (inclusive-to? true)
of the first pred-from time that follows the start of pred-from.
Example: (intervals (day-of-week 1) (day-of-week 3) true)
my-mapcat
(my-mapcat f coll)
seq-map
(seq-map f pred & [dont-reverse?])
Applies f to each interval yielded by pred.
As f changes intervals, an interval that was ahead can become behind, and
reciprocally. We make the assumption that f doesn't change the order of
intervals though, or it would be much harder to maintain lazyness.
shift-duration
(shift-duration base-pred duration)
Shifts base-pred forward or backward ('two days after pred')
Duration can be negative ('three hours before pred').
The resulting grain is the one just below the duration's grain
Shifted slots' width is exactly their grain
take-n
(take-n pred n & [opts])
Takes n cycles of pred. Used for 'next 2 weeks' for instance.
Goes forward for positive n, backward otherwise.
Accepts a :not-immediate option like take-the-nth
take-the-last-of
(take-the-last-of cyclic-pred base-pred)
Takes the *last* occurence of cyclic-pred *within* base-pred.
For example, cyclic-pred is 'Monday' and base-pred 'October'
take-the-nth
(take-the-nth pred n & [opts])
Builds a predicate with only the nth time slot of a presumably cyclical pred after ref-time,
backward (negative n) or forward (positive n).
Beware that 0 => first forward, but -1 => first backward
Options:
:not-immediate: if true, the first slot will be dropped if it
contains t. No effect on backward lookups (t is never containes in them).
take-the-nth-after
(take-the-nth-after cyclic-pred base-pred n & [opts])
Like take-the-nth, but takes the nth cyclic-pred *after base-pred*
(or before if n is negative.
Since pred generates sequences, it also generates sequences.
Options: :not-immediate works as usual