From 1b1aeffd79158bc973018751ea5185a730713bed Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 28 Jul 2018 20:31:01 -0400 Subject: Some small fixes for duration text serialization. --- stdlib/source/lux/time/duration.lux | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'stdlib') 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 Number)] + ["." number ("nat/." Codec) ("int/." Codec Number)] [text ("text/." Monoid) ["l" lexer]] ["e" error]] @@ -61,9 +61,9 @@ )) (do-template [ ] - [(def: #export ( duration) + [(def: #export (-> Duration Bit) - ( +0 (:representation duration)))] + (|>> :representation ( +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) -- cgit v1.2.3