]> gitweb.factorcode.org Git - factor.git/commitdiff
Add more time bindings
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 13 Jun 2010 23:25:08 +0000 (18:25 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 14 Jun 2010 00:34:18 +0000 (19:34 -0500)
basis/unix/time/time.factor

index 72132bb132fb2675effe90cd9455240d263da25c..bd3a02fcabe04a46d692f8767bf43a2a36da96f3 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel alien.syntax alien.c-types math unix.types
-classes.struct accessors ;
+USING: accessors alien.c-types alien.syntax calendar
+classes.struct kernel math unix.types ;
 IN: unix.time
 
 STRUCT: timeval
@@ -24,6 +24,15 @@ STRUCT: timespec
         swap >>nsec
         swap >>sec ;
 
+STRUCT: timezone
+    { tz_minuteswest int }
+    { tz_dsttime int } ;
+
+: timestamp>timezone ( timestamp -- timezone )
+    gmt-offset>> duration>minutes
+    1
+    \ timezone <struct-boa> ; inline
+
 STRUCT: tm
     { sec int }
     { min int }
@@ -40,3 +49,5 @@ STRUCT: tm
 FUNCTION: time_t time ( time_t* t ) ;
 FUNCTION: tm* localtime ( time_t* clock ) ;
 FUNCTION: int gettimeofday ( timespec* TP, void* TZP ) ;
+FUNCTION: int settimeofday ( timeval* TP, timezone* TZP ) ;
+FUNCTION: int adjtime ( timeval* delta, timeval* olddelta ) ;