changeset 17:2947170fcfd6

Fix sign error in clock skew correction
author Adam Chlipala <adam@chlipala.net>
date Sun, 21 Aug 2011 11:27:41 -0400
parents 2e397d373289
children 16447dc6a68c 4362b15220e4
files clock.ur examples/countdown.ur examples/countdown.urp
diffstat 3 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/clock.ur	Thu Aug 18 12:53:17 2011 -0430
+++ b/clock.ur	Sun Aug 21 11:27:41 2011 -0400
@@ -25,7 +25,7 @@
     in
         spawn (server <- rpc (serverTime ());
                local <- now;
-               set t.Skew (diffInSeconds server local));
+               set t.Skew (diffInSeconds local server));
         spawn (loop ())
     end
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/countdown.ur	Sun Aug 21 11:27:41 2011 -0400
@@ -0,0 +1,14 @@
+fun main () : transaction page =
+    start <- now;
+    deadline <- return (addSeconds start 60);
+    cl <- Clock.create 500;
+    return <xml><body onload={Clock.start cl}>
+      <dyn signal={cl <- Clock.signal cl;
+                   return <xml>
+                     {[cl]}<br/>
+                     {if cl > deadline then
+                          <xml><b>Expired</b></xml>
+                      else
+                          <xml>{[diffInSeconds cl deadline]}</xml>}
+                   </xml>}/>
+    </body></xml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/countdown.urp	Sun Aug 21 11:27:41 2011 -0400
@@ -0,0 +1,5 @@
+path META=../../meta
+library ..
+rewrite url Countdown/*
+
+countdown