# HG changeset patch # User Adam Chlipala # Date 1446396901 18000 # Node ID 14c45a0b63628fc55b04f72d07d7e48784905d0a # Parent d87d72b6e2994f777389d693e201d266bffb9ad1 Basis.fromMilliseconds diff -r d87d72b6e299 -r 14c45a0b6362 include/urweb/urweb_cpp.h --- a/include/urweb/urweb_cpp.h Sat Oct 31 19:21:05 2015 -0400 +++ b/include/urweb/urweb_cpp.h Sun Nov 01 11:55:01 2015 -0500 @@ -273,6 +273,7 @@ uw_Basis_int uw_Basis_toSeconds(struct uw_context *, uw_Basis_time); uw_Basis_int uw_Basis_diffInMilliseconds(struct uw_context *, uw_Basis_time, uw_Basis_time); uw_Basis_int uw_Basis_toMilliseconds(struct uw_context *, uw_Basis_time); +uw_Basis_time uw_Basis_fromMilliseconds(struct uw_context *, uw_Basis_int); uw_Basis_time uw_Basis_fromDatetime(struct uw_context *, uw_Basis_int, uw_Basis_int, uw_Basis_int, uw_Basis_int, uw_Basis_int, uw_Basis_int); uw_Basis_int uw_Basis_datetimeYear(struct uw_context *, uw_Basis_time); uw_Basis_int uw_Basis_datetimeMonth(struct uw_context *, uw_Basis_time); diff -r d87d72b6e299 -r 14c45a0b6362 lib/js/urweb.js --- a/lib/js/urweb.js Sat Oct 31 19:21:05 2015 -0400 +++ b/lib/js/urweb.js Sun Nov 01 11:55:01 2015 -0500 @@ -149,6 +149,10 @@ return Math.round(tm / 1000); } +function fromMilliseconds(tm) { + return tm * 1000; +} + function addSeconds(tm, n) { return tm + n * 1000000; } diff -r d87d72b6e299 -r 14c45a0b6362 lib/ur/basis.urs --- a/lib/ur/basis.urs Sat Oct 31 19:21:05 2015 -0400 +++ b/lib/ur/basis.urs Sun Nov 01 11:55:01 2015 -0500 @@ -163,6 +163,7 @@ val diffInSeconds : time -> time -> int (* Earlier time first *) val toMilliseconds : time -> int +val fromMilliseconds : int -> time val diffInMilliseconds : time -> time -> int val timef : string -> time -> string (* Uses strftime() format string *) val readUtc : string -> option time diff -r d87d72b6e299 -r 14c45a0b6362 src/c/urweb.c --- a/src/c/urweb.c Sat Oct 31 19:21:05 2015 -0400 +++ b/src/c/urweb.c Sun Nov 01 11:55:01 2015 -0500 @@ -4060,6 +4060,11 @@ return tm.seconds * 1000 + tm.microseconds / 1000; } +uw_Basis_time uw_Basis_fromMilliseconds(uw_context ctx, uw_Basis_int n) { + uw_Basis_time tm = {n / 1000, n % 1000 * 1000}; + return tm; +} + uw_Basis_int uw_Basis_diffInMilliseconds(uw_context ctx, uw_Basis_time tm1, uw_Basis_time tm2) { return uw_Basis_toMilliseconds(ctx, tm2) - uw_Basis_toMilliseconds(ctx, tm1); } diff -r d87d72b6e299 -r 14c45a0b6362 src/settings.sml --- a/src/settings.sml Sat Oct 31 19:21:05 2015 -0400 +++ b/src/settings.sml Sun Nov 01 11:55:01 2015 -0500 @@ -342,6 +342,7 @@ ("addSeconds", "addSeconds"), ("diffInSeconds", "diffInSeconds"), ("toMilliseconds", "toMilliseconds"), + ("fromMilliseconds", "fromMilliseconds"), ("diffInMilliseconds", "diffInMilliseconds"), ("fromDatetime", "fromDatetime"),