comparison 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
comparison
equal deleted inserted replaced
1971:1e360ea06a09 1972:56c68443cb9d
1 type datetime = {
2 Year : int,
3 Month : int,
4 Day : int,
5 Hour : int,
6 Minute : int,
7 Second : int
8 }
9
10 fun toTime dt : time = fromDatetime dt.Year dt.Month dt.Day
11 dt.Hour dt.Minute dt.Second
12
13 fun fromTime t : datetime = {
14 Year = datetimeYear t,
15 Month = datetimeMonth t,
16 Day = datetimeDay t,
17 Hour = datetimeHour t,
18 Minute = datetimeMinute t,
19 Second = datetimeSecond t
20 }
21
22 fun datetimef fmt dt : string = timef fmt (toTime dt)
23
24 val now : transaction datetime =
25 n <- now;
26 return (fromTime n)