aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/time/date.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/time/date.lux126
1 files changed, 62 insertions, 64 deletions
diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux
index 450ab5b0b..74f0d2b8c 100644
--- a/stdlib/source/library/lux/time/date.lux
+++ b/stdlib/source/library/lux/time/date.lux
@@ -68,77 +68,75 @@
"-")
(abstract: .public Date
- {}
-
(Record
[#year Year
#month Month
#day Nat])
- (def: .public (date year month day_of_month)
- (-> Year Month Nat (Try Date))
- (if (..invalid_day? year month day_of_month)
- (exception.except ..invalid_day [year month day_of_month])
- (#try.Success
- (:abstraction
- [#year year
- #month month
- #day day_of_month]))))
-
- (def: .public epoch
- Date
- (try.trusted
- (..date //year.epoch
- #//month.January
- ..minimum_day)))
-
- (template [<name> <type> <field>]
- [(def: .public <name>
- (-> Date <type>)
- (|>> :representation (value@ <field>)))]
-
- [year Year #year]
- [month Month #month]
- [day_of_month Nat #day]
- )
-
- (implementation: .public equivalence
- (Equivalence Date)
-
- (def: (= reference sample)
- (let [reference (:representation reference)
- sample (:representation sample)]
- (and (\ //year.equivalence =
+ [(def: .public (date year month day_of_month)
+ (-> Year Month Nat (Try Date))
+ (if (..invalid_day? year month day_of_month)
+ (exception.except ..invalid_day [year month day_of_month])
+ (#try.Success
+ (:abstraction
+ [#year year
+ #month month
+ #day day_of_month]))))
+
+ (def: .public epoch
+ Date
+ (try.trusted
+ (..date //year.epoch
+ #//month.January
+ ..minimum_day)))
+
+ (template [<name> <type> <field>]
+ [(def: .public <name>
+ (-> Date <type>)
+ (|>> :representation (value@ <field>)))]
+
+ [year Year #year]
+ [month Month #month]
+ [day_of_month Nat #day]
+ )
+
+ (implementation: .public equivalence
+ (Equivalence Date)
+
+ (def: (= reference sample)
+ (let [reference (:representation reference)
+ sample (:representation sample)]
+ (and (\ //year.equivalence =
+ (value@ #year reference)
+ (value@ #year sample))
+ (\ //month.equivalence =
+ (value@ #month reference)
+ (value@ #month sample))
+ (n.= (value@ #day reference)
+ (value@ #day sample))))))
+
+ (implementation: .public order
+ (Order Date)
+
+ (def: &equivalence ..equivalence)
+
+ (def: (< reference sample)
+ (let [reference (:representation reference)
+ sample (:representation sample)]
+ (or (\ //year.order <
(value@ #year reference)
(value@ #year sample))
- (\ //month.equivalence =
- (value@ #month reference)
- (value@ #month sample))
- (n.= (value@ #day reference)
- (value@ #day sample))))))
-
- (implementation: .public order
- (Order Date)
-
- (def: &equivalence ..equivalence)
-
- (def: (< reference sample)
- (let [reference (:representation reference)
- sample (:representation sample)]
- (or (\ //year.order <
- (value@ #year reference)
- (value@ #year sample))
- (and (\ //year.equivalence =
- (value@ #year reference)
- (value@ #year sample))
- (or (\ //month.order <
- (value@ #month reference)
- (value@ #month sample))
- (and (\ //month.order =
- (value@ #month reference)
- (value@ #month sample))
- (n.< (value@ #day reference)
- (value@ #day sample)))))))))
+ (and (\ //year.equivalence =
+ (value@ #year reference)
+ (value@ #year sample))
+ (or (\ //month.order <
+ (value@ #month reference)
+ (value@ #month sample))
+ (and (\ //month.order =
+ (value@ #month reference)
+ (value@ #month sample))
+ (n.< (value@ #day reference)
+ (value@ #day sample)))))))))]
)
(def: section_parser