]> gitweb.factorcode.org Git - factor.git/blob - extra/unix/time/time.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / extra / unix / time / time.factor
1
2 USING: kernel alien.syntax alien.c-types math ;
3
4 IN: unix.time
5
6 TYPEDEF: uint time_t
7
8 C-STRUCT: tm
9     { "int" "sec" }    ! Seconds: 0-59 (K&R says 0-61?)
10     { "int" "min" }    ! Minutes: 0-59
11     { "int" "hour" }   ! Hours since midnight: 0-23
12     { "int" "mday" }   ! Day of the month: 1-31
13     { "int" "mon" }    ! Months *since* january: 0-11
14     { "int" "year" }   ! Years since 1900
15     { "int" "wday" }   ! Days since Sunday (0-6)
16     { "int" "yday" }   ! Days since Jan. 1: 0-365
17     { "int" "isdst" }  ! +1 Daylight Savings Time, 0 No DST,
18     { "long" "gmtoff" } ! Seconds: 0-59 (K&R says 0-61?)
19     { "char*" "zone" } ;
20
21 C-STRUCT: timespec
22     { "time_t" "sec" }
23     { "long" "nsec" } ;
24
25 : make-timespec ( ms -- timespec )
26     1000 /mod 1000000 *
27     "timespec" <c-object>
28     [ set-timespec-nsec ] keep
29     [ set-timespec-sec ] keep ;
30
31 FUNCTION: time_t time ( time_t* t ) ;
32 FUNCTION: tm* localtime ( time_t* clock ) ;
33 FUNCTION: int gettimeofday ( timespec* TP, void* TZP ) ;