diff options
Diffstat (limited to 'stdlib/source/lux/time/day.lux')
-rw-r--r-- | stdlib/source/lux/time/day.lux | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/stdlib/source/lux/time/day.lux b/stdlib/source/lux/time/day.lux new file mode 100644 index 000000000..2288111d7 --- /dev/null +++ b/stdlib/source/lux/time/day.lux @@ -0,0 +1,76 @@ +(.module: + [lux #* + [control + [equivalence (#+ Equivalence)] + [order (#+ Order)] + [enum (#+ Enum)]]]) + +(type: #export Day + #Sunday + #Monday + #Tuesday + #Wednesday + #Thursday + #Friday + #Saturday) + +(structure: #export equivalence (Equivalence Day) + (def: (= reference sample) + (case [reference sample] + (^template [<tag>] + [<tag> <tag>] + #1) + ([#Sunday] + [#Monday] + [#Tuesday] + [#Wednesday] + [#Thursday] + [#Friday] + [#Saturday]) + + _ + #0))) + +(def: (day-to-nat day) + (-> Day Nat) + (case day + #Sunday 0 + #Monday 1 + #Tuesday 2 + #Wednesday 3 + #Thursday 4 + #Friday 5 + #Saturday 6)) + +(`` (structure: #export order (Order Day) + (def: &equivalence ..equivalence) + (~~ (do-template [<name> <comp>] + [(def: (<name> reference sample) + (<comp> (day-to-nat reference) (day-to-nat sample)))] + + [< n/<] + [<= n/<=] + [> n/>] + [>= n/>=] + )))) + +(structure: #export enum (Enum Day) + (def: &order ..order) + (def: (succ day) + (case day + #Sunday #Monday + #Monday #Tuesday + #Tuesday #Wednesday + #Wednesday #Thursday + #Thursday #Friday + #Friday #Saturday + #Saturday #Sunday)) + (def: (pred day) + (case day + #Monday #Sunday + #Tuesday #Monday + #Wednesday #Tuesday + #Thursday #Wednesday + #Friday #Thursday + #Saturday #Friday + #Sunday #Saturday))) |