1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien alien.c-types alien.syntax arrays calendar
4 kernel math unix unix.time namespaces system ;
7 : timeval>seconds ( timeval -- seconds )
8 [ timeval-sec seconds ] [ timeval-usec microseconds ] bi
11 : timeval>unix-time ( timeval -- timestamp )
12 timeval>seconds since-1970 ;
14 : timespec>seconds ( timespec -- seconds )
15 [ timespec-sec seconds ] [ timespec-nsec nanoseconds ] bi
18 : timespec>unix-time ( timespec -- timestamp )
19 timespec>seconds since-1970 ;
21 : get-time ( -- alien )
22 f time <uint> localtime ;
24 : timezone-name ( -- string )
27 M: unix gmt-offset ( -- hours minutes seconds )
28 get-time tm-gmtoff 3600 /mod 60 /mod ;