Add time vocab that can set system clock time

db4
Doug Coleman 2010-06-13 18:30:05 -05:00
parent d050ad5906
commit c59b71d6ae
6 changed files with 34 additions and 0 deletions

1
extra/time/authors.txt Normal file
View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,15 @@
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.data calendar calendar.unix classes.struct
io.files.info.unix.private kernel system time unix unix.time ;
IN: time.macosx
M: macosx adjust-time-monotonic
timestamp>timeval
\ timeval <struct>
[ adjtime io-error ] keep dup binary-zero? [
drop instant
] [
timeval>duration since-1970 now time-
] if ;

7
extra/time/time.factor Normal file
View File

@ -0,0 +1,7 @@
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: system ;
IN: time
HOOK: set-time os ( timestamp -- )
HOOK: adjust-time-monotonic os ( timestamp -- seconds )

View File

@ -0,0 +1 @@
Doug Coleman

View File

@ -0,0 +1,9 @@
! Copyright (C) 2010 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: calendar kernel math system time unix unix.time ;
IN: time.unix
M: unix set-time
[ unix-1970 time- duration>microseconds >integer make-timeval ]
[ timestamp>timezone ] bi
settimeofday io-error ;