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.lux33
1 files changed, 16 insertions, 17 deletions
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index e4e079983..2901d5828 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -8,9 +8,8 @@
[monad #+ do Monad]
["p" parser])
(data [text "text/" Monoid<Text>]
- (text ["l" lexer]
- format)
- [number]
+ (text ["l" lexer])
+ [number "int/" Codec<Text,Int>]
["R" result]
(coll [list "L/" Fold<List> Functor<List>]
["v" vector "v/" Functor<Vector> Fold<Vector>]))
@@ -30,9 +29,9 @@
(-> Instant Int)
(|>. @repr))
- (def: #export (span param subject)
+ (def: #export (span from to)
(-> Instant Instant duration;Duration)
- (duration;from-millis (i.- (@repr param) (@repr subject))))
+ (duration;from-millis (i.- (@repr from) (@repr to))))
(def: #export (shift duration instant)
(-> duration;Duration Instant Instant)
@@ -133,8 +132,8 @@
(def: (pad value)
(-> Int Text)
(if (i.< 10 value)
- (text/append "0" (%i value))
- (%i value)))
+ (text/append "0" (int/encode value))
+ (int/encode value)))
(def: (adjust-negative space duration)
(-> duration;Duration duration;Duration duration;Duration)
@@ -145,10 +144,10 @@
(def: (encode-millis millis)
(-> Int Text)
(cond (i.= 0 millis) ""
- (i.< 10 millis) (format ".00" (%i millis))
- (i.< 100 millis) (format ".0" (%i millis))
+ (i.< 10 millis) ($_ text/append ".00" (int/encode millis))
+ (i.< 100 millis) ($_ text/append ".0" (int/encode millis))
## (i.< 1_000 millis)
- (format "." (%i millis))))
+ ($_ text/append "." (int/encode millis))))
(def: seconds-per-day Int (duration;query duration;second duration;day))
(def: days-up-to-epoch Int 719468)
@@ -202,13 +201,13 @@
[minutes day-time] [(duration;query duration;minute day-time) (duration;frame duration;minute day-time)]
[seconds millis] [(duration;query duration;second day-time) (duration;frame duration;second day-time)]
]
- (format (%i year) "-" (pad month) "-" (pad day) "T"
- (pad hours) ":" (pad minutes) ":" (pad seconds)
- (|> millis
- (adjust-negative duration;second)
- duration;to-millis
- encode-millis)
- "Z")))
+ ($_ text/append (int/encode year) "-" (pad month) "-" (pad day) "T"
+ (pad hours) ":" (pad minutes) ":" (pad seconds)
+ (|> millis
+ (adjust-negative duration;second)
+ duration;to-millis
+ encode-millis)
+ "Z")))
## Codec::decode
(def: lex-year