From: Chris Hanson Date: Tue, 23 Apr 1996 20:44:15 +0000 (+0000) Subject: Add time-zone information to decoded-time structure. X-Git-Tag: 20090517-FFI~5606 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=a2e6b5f136fa44804d05a81182172add5e6c27a7;p=mit-scheme.git Add time-zone information to decoded-time structure. --- diff --git a/v7/src/microcode/dosenv.c b/v7/src/microcode/dosenv.c index 03d0a81ad..e4fbf731f 100644 --- a/v7/src/microcode/dosenv.c +++ b/v7/src/microcode/dosenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: dosenv.c,v 1.8 1995/04/23 03:16:35 cph Exp $ +$Id: dosenv.c,v 1.9 1996/04/23 20:40:19 cph Exp $ -Copyright (c) 1992-95 Massachusetts Institute of Technology +Copyright (c) 1992-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -56,6 +56,9 @@ DEFUN (OS_decode_time, (t, buffer), time_t t AND struct time_structure * buffer) (buffer -> minute) = (ts -> tm_min); (buffer -> second) = (ts -> tm_sec); (buffer -> daylight_savings_time) = (ts -> tm_isdst); + /* I'm assuming that `timezone' is implemented by the C library; + this might need conditionalization. -- cph */ + (buffer -> time_zone) = timezone; { /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */ int wday = (ts -> tm_wday); @@ -77,6 +80,11 @@ DEFUN (OS_encode_time ,(buffer), struct time_structure * buffer) (ts -> tm_sec) = (buffer -> second); (ts -> tm_isdst) = (buffer -> daylight_savings_time); STD_UINT_SYSTEM_CALL (syscall_mktime, t, (DOS_mktime (ts))); + /* mktime assumes its argument is local time, and converts it to + UTC; if the specified time zone is different, adjust the result. */ + if (((buffer -> time_zone) != INT_MAX) + && ((buffer -> time_zone) != timezone)) + t = ((t - timezone) + (buffer -> time_zone)); return (t); } diff --git a/v7/src/microcode/ntenv.c b/v7/src/microcode/ntenv.c index 9587a49b0..98465a51c 100644 --- a/v7/src/microcode/ntenv.c +++ b/v7/src/microcode/ntenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: ntenv.c,v 1.12 1995/04/23 03:16:24 cph Exp $ +$Id: ntenv.c,v 1.13 1996/04/23 20:40:11 cph Exp $ -Copyright (c) 1992-95 Massachusetts Institute of Technology +Copyright (c) 1992-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -59,6 +59,9 @@ DEFUN (OS_decode_time, (t, buffer), time_t t AND struct time_structure * buffer) (buffer -> minute) = (ts -> tm_min); (buffer -> second) = (ts -> tm_sec); (buffer -> daylight_savings_time) = (ts -> tm_isdst); + /* I'm assuming that `timezone' is implemented by the C library; + this might need conditionalization. -- cph */ + (buffer -> time_zone) = timezone; { /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */ int wday = (ts -> tm_wday); @@ -80,6 +83,11 @@ DEFUN (OS_encode_time ,(buffer), struct time_structure * buffer) (ts -> tm_sec) = (buffer -> second); (ts -> tm_isdst) = (buffer -> daylight_savings_time); STD_UINT_SYSTEM_CALL (syscall_mktime, t, (NT_mktime (ts))); + /* mktime assumes its argument is local time, and converts it to + UTC; if the specified time zone is different, adjust the result. */ + if (((buffer -> time_zone) != INT_MAX) + && ((buffer -> time_zone) != timezone)) + t = ((t - timezone) + (buffer -> time_zone)); return (t); } diff --git a/v7/src/microcode/os2env.c b/v7/src/microcode/os2env.c index 078221f05..5cf570c99 100644 --- a/v7/src/microcode/os2env.c +++ b/v7/src/microcode/os2env.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: os2env.c,v 1.9 1995/10/15 00:37:52 cph Exp $ +$Id: os2env.c,v 1.10 1996/04/23 20:40:03 cph Exp $ -Copyright (c) 1994-95 Massachusetts Institute of Technology +Copyright (c) 1994-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -93,6 +93,11 @@ OS_decode_time (time_t t, struct time_structure * buffer) (buffer -> minute) = (ts -> tm_min); (buffer -> second) = (ts -> tm_sec); (buffer -> daylight_savings_time) = (ts -> tm_isdst); +#ifdef NC_TIMEZONE + (buffer -> time_zone) = NC_TIMEZONE; +#else + (buffer -> time_zone) = INT_MAX; +#endif { /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */ int wday = (ts -> tm_wday); @@ -115,6 +120,13 @@ OS_encode_time (struct time_structure * buffer) time_t t = (mktime (&ts)); if (t < 0) OS2_error_system_call (errno, syscall_mktime); +#ifdef NC_TIMEZONE + /* mktime assumes its argument is local time, and converts it to + UTC; if the specified time zone is different, adjust the result. */ + if (((buffer -> time_zone) != INT_MAX) + && ((buffer -> time_zone) != NC_TIMEZONE)) + t = ((t - NC_TIMEZONE) + (buffer -> time_zone)); +#endif return (t); } } @@ -124,6 +136,8 @@ OS2_timezone (void) { #ifdef NC_TIMEZONE return (NC_TIMEZONE); +#else + return (0); #endif } @@ -132,6 +146,8 @@ OS2_daylight_savings_p (void) { #ifdef NC_DAYLIGHT return (NC_DAYLIGHT); +#else + return (-1); #endif } diff --git a/v7/src/microcode/osenv.h b/v7/src/microcode/osenv.h index 475b57e5c..8666be879 100644 --- a/v7/src/microcode/osenv.h +++ b/v7/src/microcode/osenv.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: osenv.h,v 1.6 1995/04/23 03:04:07 cph Exp $ +$Id: osenv.h,v 1.7 1996/04/23 20:39:46 cph Exp $ -Copyright (c) 1990-95 Massachusetts Institute of Technology +Copyright (c) 1990-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -47,6 +47,7 @@ struct time_structure unsigned int second; unsigned int day_of_week; int daylight_savings_time; + int time_zone; }; extern time_t EXFUN (OS_encoded_time, ()); diff --git a/v7/src/microcode/prosenv.c b/v7/src/microcode/prosenv.c index 4ada32896..80aa5ef89 100644 --- a/v7/src/microcode/prosenv.c +++ b/v7/src/microcode/prosenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: prosenv.c,v 1.12 1995/04/23 03:03:31 cph Exp $ +$Id: prosenv.c,v 1.13 1996/04/23 20:39:56 cph Exp $ -Copyright (c) 1987-95 Massachusetts Institute of Technology +Copyright (c) 1987-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -38,6 +38,7 @@ MIT in each case. */ #include "prims.h" #include "osenv.h" #include "ostop.h" +#include "limits.h" DEFINE_PRIMITIVE ("ENCODED-TIME", Prim_encoded_time, 0, 0, "Return the current time as an integer.") @@ -48,7 +49,7 @@ DEFINE_PRIMITIVE ("ENCODED-TIME", Prim_encoded_time, 0, 0, DEFINE_PRIMITIVE ("DECODE-TIME", Prim_decode_time, 2, 2, "Fill a vector with the second argument decoded.\n\ The vector's elements are:\n\ - #(TAG second minute hour day month year day-of-week dst)") + #(TAG second minute hour day month year day-of-week dst zone)") { SCHEME_OBJECT vec; unsigned int len; @@ -69,6 +70,12 @@ The vector's elements are:\n\ FAST_VECTOR_SET (vec, 7, (long_to_integer (ts . day_of_week))); if (len > 8) FAST_VECTOR_SET (vec, 8, (long_to_integer (ts . daylight_savings_time))); + if (len > 9) + FAST_VECTOR_SET + (vec, 9, + (((ts . time_zone) == INT_MAX) + ? SHARP_F + : (long_to_integer (ts . time_zone)))); PRIMITIVE_RETURN (UNSPECIFIC); } @@ -95,6 +102,12 @@ DEFINE_PRIMITIVE ("ENCODE-TIME", Prim_encode_time, 1, 1, = ((len > 8) ? (integer_to_long (FAST_VECTOR_REF (vec, 8))) : (-1)); + (ts . time_zone) + = (((len > 9) + && (INTEGER_P (FAST_VECTOR_REF (vec, 9))) + && (integer_to_long_p (FAST_VECTOR_REF (vec, 9)))) + ? (integer_to_long (FAST_VECTOR_REF (vec, 9))) + : INT_MAX); PRIMITIVE_RETURN (long_to_integer ((long) (OS_encode_time (&ts)))); } diff --git a/v7/src/microcode/ux.h b/v7/src/microcode/ux.h index 83b53ba49..4051017eb 100644 --- a/v7/src/microcode/ux.h +++ b/v7/src/microcode/ux.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: ux.h,v 1.62 1995/06/29 23:47:45 cph Exp $ +$Id: ux.h,v 1.63 1996/04/23 20:42:41 cph Exp $ -Copyright (c) 1988-94 Massachusetts Institute of Technology +Copyright (c) 1988-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -197,6 +197,7 @@ extern int EXFUN (kill, (pid_t, int)); #define HAVE_GETCWD #define HAVE_TERMIO #define HAVE_TIMES +#define HAVE_TIMEZONE #define AMBIGUOUS_NONBLOCK #define ERRNO_NONBLOCK EAGAIN @@ -281,6 +282,8 @@ extern int EXFUN (kill, (pid_t, int)); #define SYSTEM_VARIANT "Linux" #include #define HAVE_FTRUNCATE +#define HAVE_STATFS +#define HAVE_TIMEZONE #endif #ifdef _ULTRIX @@ -706,6 +709,7 @@ extern char * EXFUN (getlogin, (void)); #define UX_dup dup #define UX_free free #define UX_fstat fstat +#define UX_fstatfs fstatfs #define UX_getegid getegid #define UX_getenv getenv #define UX_geteuid geteuid @@ -731,6 +735,7 @@ extern char * EXFUN (getlogin, (void)); #define UX_signal signal #define UX_sleep sleep #define UX_stat stat +#define UX_statfs statfs #define UX_system system #define UX_time time #define UX_unlink unlink diff --git a/v7/src/microcode/uxenv.c b/v7/src/microcode/uxenv.c index 8ba47f409..3a8fcdf3f 100644 --- a/v7/src/microcode/uxenv.c +++ b/v7/src/microcode/uxenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: uxenv.c,v 1.14 1995/04/23 03:16:42 cph Exp $ +$Id: uxenv.c,v 1.15 1996/04/23 20:44:15 cph Exp $ -Copyright (c) 1990-95 Massachusetts Institute of Technology +Copyright (c) 1990-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -56,6 +56,11 @@ DEFUN (OS_decode_time, (t, buffer), time_t t AND struct time_structure * buffer) (buffer -> minute) = (ts -> tm_min); (buffer -> second) = (ts -> tm_sec); (buffer -> daylight_savings_time) = (ts -> tm_isdst); +#ifdef HAVE_TIMEZONE + (buffer -> time_zone) = timezone; +#else + (buffer -> time_zone) = INT_MAX; +#endif { /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */ int wday = (ts -> tm_wday); @@ -80,6 +85,13 @@ DEFUN (OS_encode_time ,(buffer), struct time_structure * buffer) STD_UINT_SYSTEM_CALL (syscall_mktime, t, (UX_mktime (ts))); #else error_system_call (ENOSYS, syscall_mktime); +#endif +#ifdef HAVE_TIMEZONE + /* mktime assumes its argument is local time, and converts it to + UTC; if the specified time zone is different, adjust the result. */ + if (((buffer -> time_zone) != INT_MAX) + && ((buffer -> time_zone) != timezone)) + t = ((t - timezone) + (buffer -> time_zone)); #endif return (t); }