diff lib/ur/datetime.ur @ 1972:56c68443cb9d

Basic datetime library.
author Patrick Hurst <phurst@mit.edu>
date Thu, 05 Dec 2013 11:36:46 -0500
parents
children 155bd0bc4d28
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/ur/datetime.ur	Thu Dec 05 11:36:46 2013 -0500
@@ -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)