summaryrefslogtreecommitdiff
path: root/lib/ur/datetime.ur
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ur/datetime.ur')
-rw-r--r--lib/ur/datetime.ur26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/ur/datetime.ur b/lib/ur/datetime.ur
new file mode 100644
index 00000000..56c29724
--- /dev/null
+++ b/lib/ur/datetime.ur
@@ -0,0 +1,26 @@
+type datetime = {
+ Year : int,
+ Month : int,
+ Day : int,
+ Hour : int,
+ Minute : int,
+ Second : int
+}
+
+fun toTime dt : time = fromDatetime dt.Year dt.Month dt.Day
+ dt.Hour dt.Minute dt.Second
+
+fun fromTime t : datetime = {
+ Year = datetimeYear t,
+ Month = datetimeMonth t,
+ Day = datetimeDay t,
+ Hour = datetimeHour t,
+ Minute = datetimeMinute t,
+ Second = datetimeSecond t
+}
+
+fun datetimef fmt dt : string = timef fmt (toTime dt)
+
+val now : transaction datetime =
+ n <- now;
+ return (fromTime n)