aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/time/instant.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/time/instant.lux39
1 files changed, 23 insertions, 16 deletions
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index ebe637217..a05513374 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -3,6 +3,7 @@
(lux [io #- run]
(control eq
order
+ enum
codec
[monad #+ do Monad]
["p" parser])
@@ -33,22 +34,6 @@
(-> Instant Instant duration;Duration)
(duration;from-millis (i.- (@repr param) (@repr subject))))
- (struct: #export _ (Eq Instant)
- (def: (= param subject)
- (i.= (@repr param) (@repr subject))))
-
- (struct: #export _ (Order Instant)
- (def: eq Eq<Instant>)
- (do-template [<name> <op>]
- [(def: (<name> param subject)
- (<op> (@repr param) (@repr subject)))]
-
- [< i.<]
- [<= i.<=]
- [> i.>]
- [>= i.>=]
- ))
-
(def: #export (shift duration instant)
(-> duration;Duration Instant Instant)
(@model (i.+ (duration;to-millis duration) (@repr instant))))
@@ -60,6 +45,28 @@
(def: #export (absolute offset)
(-> duration;Duration Instant)
(|> offset duration;to-millis @model))
+
+ (struct: #export _ (Eq Instant)
+ (def: (= param subject)
+ (:: number;Eq<Int> = (@repr param) (@repr subject))))
+
+ (struct: #export _ (Order Instant)
+ (def: eq Eq<Instant>)
+ (do-template [<name>]
+ [(def: (<name> param subject)
+ (:: number;Order<Int> <name> (@repr param) (@repr subject)))]
+
+ [<] [<=] [>] [>=]
+ ))
+
+ (struct: #export _ (Enum Instant)
+ (def: order Order<Instant>)
+ (do-template [<name>]
+ [(def: <name>
+ (|>. @repr (:: number;Enum<Int> <name>) @model))]
+
+ [succ] [pred]
+ ))
)
(def: #export epoch