diff options
author | 2012-02-04 11:01:06 -0500 | |
---|---|---|
committer | 2012-02-04 11:01:06 -0500 | |
commit | 09c2534e57944a9b5d6cc8971d0733d25749ade5 (patch) | |
tree | e85b1d872c1f40a0b7ba471cf80d0787e65c7eb7 /src | |
parent | 36603eae600143253959ad94cdc5bb75a766b91c (diff) |
Basis.toMilliseconds and diffInMilliseconds, based on a patch from Gergely Buday
Diffstat (limited to 'src')
-rw-r--r-- | src/c/urweb.c | 8 | ||||
-rw-r--r-- | src/settings.sml | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 738c765c..0b04f665 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3681,6 +3681,14 @@ uw_Basis_int uw_Basis_diffInSeconds(uw_context ctx, uw_Basis_time tm1, uw_Basis_ return difftime(tm2.seconds, tm1.seconds); } +uw_Basis_int uw_Basis_toMilliseconds(uw_context ctx, uw_Basis_time tm) { + return tm.seconds * 1000 + tm.microseconds / 1000; +} + +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); +} + uw_Basis_int uw_Basis_toSeconds(uw_context ctx, uw_Basis_time tm) { return tm.seconds; } diff --git a/src/settings.sml b/src/settings.sml index 017c5095..3adf81c8 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -286,6 +286,8 @@ val jsFuncsBase = basisM [("alert", "alert"), ("toSeconds", "toSeconds"), ("addSeconds", "addSeconds"), ("diffInSeconds", "diffInSeconds"), + ("toMilliseconds", "toMilliseconds"), + ("diffInMilliseconds", "diffInMilliseconds"), ("onClick", "uw_onClick"), ("onDblclick", "uw_onDblclick"), |