Add time-+ / time-delta tools
authorChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 19 Nov 2015 20:22:36 +0000 (14:22 -0600)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Thu, 19 Nov 2015 20:22:36 +0000 (14:22 -0600)
loopy.scm

index 5c1455ecc86cc8f0f5eeed9b6f21da86d8a98a32..70d2d08ba7e2b42083452a3d5f30e8fe8f93f508 100644 (file)
--- a/loopy.scm
+++ b/loopy.scm
             make-time-segment time-segment?
             time-segment-time time-segment-queue
 
-            time-< time-= time-<=
+            time-< time-= time-<= time-+
+
+            <time-delta>
+            make-time-delta time-delta?
+            time-delta-sec time-delta-usec
 
             <schedule>
             make-schedule schedule?
   (or (time-< time1 time2)
       (time-= time1 time2)))
 
+
+(define-record-type <time-delta>
+  (make-time-delta-intern sec usec)
+  time-delta?
+  (sec time-delta-sec)
+  (usec time-delta-usec))
+
+(define* (make-time-delta sec #:optional usec)
+  (make-time-delta-intern sec (or usec 0)))
+
+(define (time-+ time time-delta)
+  (cons (+ (car time) (time-delta-sec time-delta))
+        (+ (cdr time) (time-delta-usec time-delta))))
+
+
 (define-record-type <schedule>
   (make-schedule-intern segments)
   schedule?