From e92f7da685b9719f2aea67e4ebe630b98715368f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 29 Jul 2017 10:32:01 -0400 Subject: - Added "month" function and improved "day" function. --- stdlib/source/lux/time/instant.lux | 17 ++++++++++++----- 1 file 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 Functor] ["v" vector "v/" Functor Fold])) (type model)) - (.. [duration "duration/" ;Order] + (.. [duration "duration/" Order] [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 -- cgit v1.2.3