summaryrefslogtreecommitdiff
path: root/lib/date
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-22 00:26:54 -0700
committerOri Bernstein <ori@eigenstate.org>2015-09-22 09:43:57 -0700
commita547a3f019967cd0609eced8cdfa01b550ec0aaf (patch)
tree437f041e2e49de0f21aa5c68252c23bfd4b19f09 /lib/date
parentf2854813a1a6c4603480af0a23d62d60fff770a2 (diff)
downloadmc-a547a3f019967cd0609eced8cdfa01b550ec0aaf.tar.gz
Add constructors for ymd and ymdhms
Diffstat (limited to 'lib/date')
-rw-r--r--lib/date/date.myr14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/date/date.myr b/lib/date/date.myr
index afdbe09..095e77f 100644
--- a/lib/date/date.myr
+++ b/lib/date/date.myr
@@ -7,6 +7,9 @@ pkg date =
const utcnow : (-> instant)
const now : (tz : byte[:] -> instant)
const tozone : (d : instant, zone : byte[:] -> instant)
+ const mkdate : (y : int, m : int, day : int, zone : byte[:] -> instant)
+ const mkdatetime : (year : int, mon : int, day : int, \
+ h : int, m : int, s : int, zone : byte[:] -> instant)
const mkinstant : (tm : std.time, zone : byte[:] -> instant)
const localoff : (tm : std.time -> duration)
@@ -42,6 +45,17 @@ const tozone = {d, tz
-> mkinstant(d.actual, tz)
}
+const mkdate = {y, m, d, tz
+ -> mkinstant(recalc([.year=y, .mon=m, .day=d]), tz)
+}
+
+const mkdatetime = {year, mon, day, h, m, s, tz
+ -> mkinstant(recalc([
+ .year=year, .mon=mon, .day=day,
+ .h=h, .m=m, .s=s
+ ]), tz)
+}
+
const mkinstant = {tm, tz
var j, y, m, d
var t, e