From 4e2ca568001fd64de9eb056ee73e07387e2d5ebd Mon Sep 17 00:00:00 2001 From: erg Date: Fri, 1 Sep 2006 21:45:00 +0000 Subject: [PATCH] calendar changes --- contrib/calendar/calendar.factor | 6 +++--- contrib/calendar/load.factor | 18 +++++++++++----- contrib/calendar/os-unix.factor | 4 ++++ contrib/calendar/os-win32.factor | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 contrib/calendar/os-unix.factor create mode 100644 contrib/calendar/os-win32.factor diff --git a/contrib/calendar/calendar.factor b/contrib/calendar/calendar.factor index 83d39c866e..a329c206d3 100644 --- a/contrib/calendar/calendar.factor +++ b/contrib/calendar/calendar.factor @@ -6,10 +6,10 @@ TUPLE: timestamp year month day hour minute second gmt-offset ; TUPLE: dt year month day hour minute second ; SYMBOL: gmt-offset -7 gmt-offset set-global +-6 gmt-offset set-global ! central time -FUNCTION: time_t time ( time_t* tloc ) ; -FUNCTION: tm* localtime ( time_t* clock ) ; +LIBRARY: libc +FUNCTION: time_t time ( time_t* t ) ; : month-names { diff --git a/contrib/calendar/load.factor b/contrib/calendar/load.factor index 491ec78a2a..6fedb3dae4 100644 --- a/contrib/calendar/load.factor +++ b/contrib/calendar/load.factor @@ -1,6 +1,14 @@ -PROVIDE: calendar +USING: kernel modules sequences ; +"calendar" + { - "calendar.factor" -} { - "test/calendar.factor" -} ; + { [ win32? ] [ { "os-win32.factor" } ] } + { [ t ] [ { "os-unix.factor" } ] } +} cond +{ + "calendar.factor" +} append + +{ "test/calendar.factor" } +provide + diff --git a/contrib/calendar/os-unix.factor b/contrib/calendar/os-unix.factor new file mode 100644 index 0000000000..2d37f2df92 --- /dev/null +++ b/contrib/calendar/os-unix.factor @@ -0,0 +1,4 @@ +IN: calendar +USING: alien ; + +TYPEDEF: uint time_t diff --git a/contrib/calendar/os-win32.factor b/contrib/calendar/os-win32.factor new file mode 100644 index 0000000000..f8cdf34edd --- /dev/null +++ b/contrib/calendar/os-win32.factor @@ -0,0 +1,36 @@ +IN: calendar +USING: alien kernel math win32-api ; + + + + +: tz "_TIME_ZONE_INFORMATION" dup GetTimeZoneInformation + TIME_ZONE_ID_INVALID = [ + win32-error + ] when alien-address 4 + alien>u16-string ; + + + + + + + + +! TYPEDEF: longlong time_t +! TYPEDEF: longlong __time64_t +! TYPEDEF: int errno_t +! +! BEGIN-STRUCT: tm + ! FIELD: int tm_sec; ! Seconds: 0-59 (K&R says 0-61?) + ! FIELD: int tm_min; ! Minutes: 0-59 + ! FIELD: int tm_hour; ! Hours since midnight: 0-23 + ! FIELD: int tm_mday; ! Day of the month: 1-31 + ! FIELD: int tm_mon; ! Months *since* january: 0-11 + ! FIELD: int tm_year; ! Years since 1900 + ! FIELD: int tm_wday; ! Days since Sunday (0-6) + ! FIELD: int tm_yday; ! Days since Jan. 1: 0-365 + ! FIELD: int tm_isdst ! +1 Daylight Savings Time, 0 No DST, +! END-STRUCT +! +! FUNCTION: errno_t _localtime64_s ( tm* _tm, __time64_t *time ) ; +