summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/urweb/urweb_cpp.h1
-rw-r--r--lib/js/urweb.js4
-rw-r--r--lib/ur/basis.urs1
-rw-r--r--src/c/urweb.c5
-rw-r--r--src/settings.sml1
5 files changed, 12 insertions, 0 deletions
diff --git a/include/urweb/urweb_cpp.h b/include/urweb/urweb_cpp.h
index a371d8e8..5aa6ec69 100644
--- a/include/urweb/urweb_cpp.h
+++ b/include/urweb/urweb_cpp.h
@@ -273,6 +273,7 @@ uw_Basis_int uw_Basis_diffInSeconds(struct uw_context *, uw_Basis_time, uw_Basis
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 --git a/lib/js/urweb.js b/lib/js/urweb.js
index 335cb525..ac4e4c9e 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -149,6 +149,10 @@ function toMilliseconds(tm) {
return Math.round(tm / 1000);
}
+function fromMilliseconds(tm) {
+ return tm * 1000;
+}
+
function addSeconds(tm, n) {
return tm + n * 1000000;
}
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index ec6ef599..e4eaa0a9 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -163,6 +163,7 @@ val toSeconds : time -> int
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 --git a/src/c/urweb.c b/src/c/urweb.c
index 1ef6600c..169152dc 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -4060,6 +4060,11 @@ uw_Basis_int uw_Basis_toMilliseconds(uw_context ctx, uw_Basis_time tm) {
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 --git a/src/settings.sml b/src/settings.sml
index bea26103..0140ddc0 100644
--- a/src/settings.sml
+++ b/src/settings.sml
@@ -342,6 +342,7 @@ val jsFuncsBase = basisM [("alert", "alert"),
("addSeconds", "addSeconds"),
("diffInSeconds", "diffInSeconds"),
("toMilliseconds", "toMilliseconds"),
+ ("fromMilliseconds", "fromMilliseconds"),
("diffInMilliseconds", "diffInMilliseconds"),
("fromDatetime", "fromDatetime"),