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