aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/time/instant.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/time/instant.lux')
-rw-r--r--stdlib/source/lux/time/instant.lux12
1 files changed, 9 insertions, 3 deletions
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 7c63b7d31..195d78e83 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -90,7 +90,7 @@
(def: millis-per-day
(duration.query duration.milli-second duration.day))
-(def: (date-time instant)
+(def: (split-date-time instant)
(-> Instant [Date Duration])
(let [offset (..to-millis instant)
bce? (i.< +0 offset)
@@ -119,7 +119,7 @@
(def: (encode instant)
(-> Instant Text)
- (let [[date time] (..date-time instant)
+ (let [[date time] (..split-date-time instant)
time (..clock-time time)]
($_ text\compose
(\ date.codec encode date) ..date-suffix
@@ -155,7 +155,7 @@
(template [<field> <type> <post-processing>]
[(def: #export (<field> instant)
(-> Instant <type>)
- (let [[date time] (..date-time instant)]
+ (let [[date time] (..split-date-time instant)]
(|> <field> <post-processing>)))]
[date Date (|>)]
@@ -185,3 +185,9 @@
+5 #day.Friday
+6 #day.Saturday
_ (undefined))))
+
+(def: #export (from-date-time date time)
+ (-> Date Time Instant)
+ (..from-millis
+ (i.+ (i.* (date.days date) (duration.to-millis duration.day))
+ (.int (//.to-millis time)))))