aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2018-07-28 20:31:01 -0400
committerEduardo Julian2018-07-28 20:31:01 -0400
commit1b1aeffd79158bc973018751ea5185a730713bed (patch)
treedd6b87aaebee20824217bb9455429cbf4da27879
parent072849be197dc6bb6007d08bb26be00cc374c744 (diff)
Some small fixes for duration text serialization.
-rw-r--r--stdlib/source/lux/time/duration.lux18
1 files changed, 9 insertions, 9 deletions
diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux
index 1abac1cc0..d7b0abb24 100644
--- a/stdlib/source/lux/time/duration.lux
+++ b/stdlib/source/lux/time/duration.lux
@@ -8,7 +8,7 @@
["p" parser]
[monad (#+ do)]]
[data
- ["." number ("int/." Codec<Text,Int> Number<Int>)]
+ ["." number ("nat/." Codec<Text,Nat>) ("int/." Codec<Text,Int> Number<Int>)]
[text ("text/." Monoid<Text>)
["l" lexer]]
["e" error]]
@@ -61,9 +61,9 @@
))
(do-template [<name> <op>]
- [(def: #export (<name> duration)
+ [(def: #export <name>
(-> Duration Bit)
- (<op> +0 (:representation duration)))]
+ (|>> :representation (<op> +0)))]
[positive? i/>]
[negative? i/<]
@@ -101,12 +101,12 @@
[seconds time-left] [(query second time-left) (frame second time-left)]
millis (to-millis time-left)]
($_ text/compose
- (if signed? "-" "")
- (if (i/= +0 days) "" (text/compose (int/encode days) "D"))
- (if (i/= +0 hours) "" (text/compose (int/encode hours) "h"))
- (if (i/= +0 minutes) "" (text/compose (int/encode minutes) "m"))
- (if (i/= +0 seconds) "" (text/compose (int/encode seconds) "s"))
- (if (i/= +0 millis) "" (text/compose (int/encode millis) "ms"))
+ (if signed? "-" "+")
+ (if (i/= +0 days) "" (text/compose (nat/encode (.nat days)) "D"))
+ (if (i/= +0 hours) "" (text/compose (nat/encode (.nat hours)) "h"))
+ (if (i/= +0 minutes) "" (text/compose (nat/encode (.nat minutes)) "m"))
+ (if (i/= +0 seconds) "" (text/compose (nat/encode (.nat seconds)) "s"))
+ (if (i/= +0 millis) "" (text/compose (nat/encode (.nat millis)) "ms"))
))))
(def: (lex-section suffix)