aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/time/instant.lux17
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