diff options
author | 2013-12-05 11:36:54 -0500 | |
---|---|---|
committer | 2013-12-05 11:36:54 -0500 | |
commit | 90c266db553a99056e0baac98df05f06c34de4ae (patch) | |
tree | 522d24017236006718a02bf6e4c092f567c7888b | |
parent | 5892c59cc4dd947692ff1503b39ab7dc4e02037b (diff) |
Day of week functions.
-rw-r--r-- | lib/ur/basis.urs | 1 | ||||
-rw-r--r-- | lib/ur/datetime.ur | 12 | ||||
-rw-r--r-- | lib/ur/datetime.urs | 5 | ||||
-rw-r--r-- | src/c/urweb.c | 5 |
4 files changed, 23 insertions, 0 deletions
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 804f15b9..36d2effa 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -175,6 +175,7 @@ val datetimeDay : time -> int val datetimeHour : time -> int val datetimeMinute: time -> int val datetimeSecond : time -> int +val datetimeDayOfWeek : time -> int (** * Encryption *) diff --git a/lib/ur/datetime.ur b/lib/ur/datetime.ur index 56c29724..a633dc83 100644 --- a/lib/ur/datetime.ur +++ b/lib/ur/datetime.ur @@ -7,6 +7,18 @@ type datetime = { Second : int } +datatype day_of_week = Sunday | Monday | Tuesday | Wednesday | Thursday | + Friday | Saturday + +val show = mkShow (fn dow => case dow of + Sunday => "Sunday" + | Monday => "Monday" + | Tuesday => "Tuesday" + | Wednesday => "Wednesday" + | Thursday => "Thursday" + | Friday => "Friday" + | Saturday => "Saturday") + fun toTime dt : time = fromDatetime dt.Year dt.Month dt.Day dt.Hour dt.Minute dt.Second diff --git a/lib/ur/datetime.urs b/lib/ur/datetime.urs index 9d99b9e3..0d8e8c28 100644 --- a/lib/ur/datetime.urs +++ b/lib/ur/datetime.urs @@ -6,6 +6,11 @@ type datetime = { Year : int, Second : int } +datatype day_of_week = Sunday | Monday | Tuesday | Wednesday | Thursday | + Friday | Saturday + +val show : show day_of_week + val toTime : datetime -> time val fromTime : time -> datetime val datetimef : string -> datetime -> string diff --git a/src/c/urweb.c b/src/c/urweb.c index cb71aa15..fb6d28c6 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3894,6 +3894,11 @@ uw_Basis_int uw_Basis_datetimeSecond(uw_context ctx, uw_Basis_time time) { return tm.tm_sec; } +uw_Basis_int uw_Basis_datetimeDayOfWeek(uw_context ctx, uw_Basis_time time) { + struct tm tm; + gmtime_r(&time.seconds, &tm); + return tm.tm_wday; +} void *uw_get_global(uw_context ctx, char *name) { |