diff options
Diffstat (limited to 'stdlib/source/lux/time/date.lux')
-rw-r--r-- | stdlib/source/lux/time/date.lux | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux index d3306f826..688546698 100644 --- a/stdlib/source/lux/time/date.lux +++ b/stdlib/source/lux/time/date.lux @@ -223,7 +223,7 @@ ## Based on this: https://stackoverflow.com/a/42936293/6823464 (def: (pad value) (-> Int Text) - (if (i/< 10 value) + (if (i/< +10 value) (text/compose "0" (int/encode value)) (int/encode value))) @@ -237,11 +237,11 @@ (def: lex-year (l.Lexer Int) (do p.Monad<Parser> - [sign? (p.maybe (l.this "-")) + [sign (p.or (l.this "-") (l.this "+")) raw-year (p.codec number.Codec<Text,Int> (l.many l.decimal)) - #let [signum (case sign? - #.None 1 - (#.Some _) -1)]] + #let [signum (case sign + (#.Left _) -1 + (#.Right _) +1)]] (wrap (i/* signum raw-year)))) (def: lex-section @@ -250,9 +250,9 @@ (def: (leap-years year) (-> Int Int) - (|> (i// 4 year) - (i/- (i// 100 year)) - (i/+ (i// 400 year)))) + (|> (i// +4 year) + (i/- (i// +100 year)) + (i/+ (i// +400 year)))) (def: normal-months (Row Nat) @@ -267,13 +267,13 @@ (def: (divisible? factor input) (-> Int Int Bit) - (|> input (i/% factor) (i/= 0))) + (|> input (i/% factor) (i/= +0))) (def: (leap-year? year) (-> Int Bit) - (and (divisible? 4 year) - (or (not (divisible? 100 year)) - (divisible? 400 year)))) + (and (divisible? +4 year) + (or (not (divisible? +100 year)) + (divisible? +400 year)))) ## Based on: https://stackoverflow.com/a/3309340/6823464 (def: lex-date @@ -283,8 +283,8 @@ _ (l.this "-") utc-month lex-section _ (p.assert "Invalid month." - (and (i/>= 1 utc-month) - (i/<= 12 utc-month))) + (and (i/>= +1 utc-month) + (i/<= +12 utc-month))) #let [months (if (leap-year? utc-year) leap-year-months normal-months) @@ -294,22 +294,22 @@ _ (l.this "-") utc-day lex-section _ (p.assert "Invalid day." - (and (i/>= 1 utc-day) + (and (i/>= +1 utc-day) (i/<= (.int month-days) utc-day)))] (wrap {#year utc-year #month (case utc-month - 1 #January - 2 #February - 3 #March - 4 #April - 5 #May - 6 #June - 7 #July - 8 #August - 9 #September - 10 #October - 11 #November - 12 #December + +1 #January + +2 #February + +3 #March + +4 #April + +5 #May + +6 #June + +7 #July + +8 #August + +9 #September + +10 #October + +11 #November + +12 #December _ (undefined)) #day (.nat utc-day)}))) |