diff options
author | Eduardo Julian | 2017-07-29 10:32:01 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-07-29 10:32:01 -0400 |
commit | e92f7da685b9719f2aea67e4ebe630b98715368f (patch) | |
tree | 798f217a84c5c49e272d4961f8873d8a8e5874b9 | |
parent | e05d0ab95cc4223824d5faffe1b7fe552127e73f (diff) |
- Added "month" function and improved "day" function.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/time/instant.lux | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux index 1fed74b24..ebe637217 100644 --- a/stdlib/source/lux/time/instant.lux +++ b/stdlib/source/lux/time/instant.lux @@ -14,7 +14,7 @@ (coll [list "L/" Fold<List> Functor<List>] ["v" vector "v/" Functor<Vector> Fold<Vector>])) (type model)) - (.. [duration "duration/" ;Order<Duration>] + (.. [duration "duration/" Order<Duration>] [date])) (model: #export Instant @@ -324,18 +324,25 @@ _ (undefined)) #date;day (int-to-nat day)})) +(def: #export (month instant) + (-> Instant date;Month) + (let [[year month day] (date instant)] + month)) + (def: #export (day instant) (-> Instant date;Day) (let [offset (relative instant) days (duration;query duration;day offset) - days (if (i.>= 0 days) - days - (i.dec days)) + day-time (duration;frame duration;day offset) + days (if (and (duration;negative? offset) + (not (duration;neutral? day-time))) + (i.dec days) + days) ## 1970/01/01 was a Thursday y1970m0d0 4] (case (|> y1970m0d0 (i.+ days) (i.% 7) - ## This is down to turn negative days into positive days. + ## This is done to turn negative days into positive days. (i.+ 7) (i.% 7)) 0 #date;Sunday 1 #date;Monday |