From 6b901d02d6c9b46e024f1ae006b097dd30ceeca5 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Sun, 23 Apr 1995 03:04:58 +0000 Subject: [PATCH] Extend the time decode/encode primitives to handle daylight savings time information. --- v7/src/microcode/dosenv.c | 5 +-- v7/src/microcode/ntenv.c | 5 +-- v7/src/microcode/os2env.c | 3 +- v7/src/microcode/osenv.h | 5 +-- v7/src/microcode/prosenv.c | 65 +++++++++++++------------------------- v7/src/microcode/uxenv.c | 5 +-- 6 files changed, 36 insertions(+), 52 deletions(-) diff --git a/v7/src/microcode/dosenv.c b/v7/src/microcode/dosenv.c index 8137f1529..13570039d 100644 --- a/v7/src/microcode/dosenv.c +++ b/v7/src/microcode/dosenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: dosenv.c,v 1.6 1993/08/28 22:46:35 gjr Exp $ +$Id: dosenv.c,v 1.7 1995/04/23 03:04:52 cph Exp $ -Copyright (c) 1992-1993 Massachusetts Institute of Technology +Copyright (c) 1992-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -55,6 +55,7 @@ DEFUN (OS_decode_time, (t, buffer), time_t t AND struct time_structure * buffer) (buffer -> hour) = (ts -> tm_hour); (buffer -> minute) = (ts -> tm_min); (buffer -> second) = (ts -> tm_sec); + (buffer -> daylight_savings_time) = (ts -> tm_isdst); { /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */ int wday = (ts -> tm_wday); diff --git a/v7/src/microcode/ntenv.c b/v7/src/microcode/ntenv.c index a3ff82a6c..e16907145 100644 --- a/v7/src/microcode/ntenv.c +++ b/v7/src/microcode/ntenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: ntenv.c,v 1.10 1994/10/25 14:36:04 adams Exp $ +$Id: ntenv.c,v 1.11 1995/04/23 03:04:00 cph Exp $ -Copyright (c) 1992-1993 Massachusetts Institute of Technology +Copyright (c) 1992-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -58,6 +58,7 @@ DEFUN (OS_decode_time, (t, buffer), time_t t AND struct time_structure * buffer) (buffer -> hour) = (ts -> tm_hour); (buffer -> minute) = (ts -> tm_min); (buffer -> second) = (ts -> tm_sec); + (buffer -> daylight_savings_time) = (ts -> tm_isdst); { /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */ int wday = (ts -> tm_wday); diff --git a/v7/src/microcode/os2env.c b/v7/src/microcode/os2env.c index 99999e37b..c5409ccf5 100644 --- a/v7/src/microcode/os2env.c +++ b/v7/src/microcode/os2env.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: os2env.c,v 1.3 1995/04/23 02:42:38 cph Exp $ +$Id: os2env.c,v 1.4 1995/04/23 03:03:44 cph Exp $ Copyright (c) 1994-95 Massachusetts Institute of Technology @@ -86,6 +86,7 @@ OS_decode_time (time_t t, struct time_structure * buffer) (buffer -> hour) = (ts -> tm_hour); (buffer -> minute) = (ts -> tm_min); (buffer -> second) = (ts -> tm_sec); + (buffer -> daylight_savings_time) = (ts -> tm_isdst); { /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */ int wday = (ts -> tm_wday); diff --git a/v7/src/microcode/osenv.h b/v7/src/microcode/osenv.h index ab80dd70d..475b57e5c 100644 --- a/v7/src/microcode/osenv.h +++ b/v7/src/microcode/osenv.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: osenv.h,v 1.5 1993/08/28 22:46:39 gjr Exp $ +$Id: osenv.h,v 1.6 1995/04/23 03:04:07 cph Exp $ -Copyright (c) 1990-1993 Massachusetts Institute of Technology +Copyright (c) 1990-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -46,6 +46,7 @@ struct time_structure unsigned int minute; unsigned int second; unsigned int day_of_week; + int daylight_savings_time; }; extern time_t EXFUN (OS_encoded_time, ()); diff --git a/v7/src/microcode/prosenv.c b/v7/src/microcode/prosenv.c index 50c75445c..4ada32896 100644 --- a/v7/src/microcode/prosenv.c +++ b/v7/src/microcode/prosenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: prosenv.c,v 1.11 1993/08/29 19:54:27 ziggy Exp $ +$Id: prosenv.c,v 1.12 1995/04/23 03:03:31 cph Exp $ -Copyright (c) 1987-1993 Massachusetts Institute of Technology +Copyright (c) 1987-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -39,36 +39,6 @@ MIT in each case. */ #include "osenv.h" #include "ostop.h" -/* This primitive is obsolete. - Left here for a while for compatibility purposes (booting old bands). - */ - -DEFINE_PRIMITIVE ("GET-DECODED-TIME", Prim_get_decoded_time, 1, 1, - "Return a vector with the current decoded time;\n\ -arg TAG is used to tag the vector.\n\ -The vector's elements are:\n\ - #(TAG second minute hour day month year day-of-week)") -{ - time_t t; - struct time_structure ts; - PRIMITIVE_HEADER (1); - - t = (OS_encoded_time ()); - OS_decode_time (t, &ts); - { - SCHEME_OBJECT result = (allocate_marked_vector (TC_VECTOR, 8, 1)); - FAST_VECTOR_SET (result, 0, (ARG_REF (1))); - FAST_VECTOR_SET (result, 1, (long_to_integer (ts . second))); - FAST_VECTOR_SET (result, 2, (long_to_integer (ts . minute))); - FAST_VECTOR_SET (result, 3, (long_to_integer (ts . hour))); - FAST_VECTOR_SET (result, 4, (long_to_integer (ts . day))); - FAST_VECTOR_SET (result, 5, (long_to_integer (ts . month))); - FAST_VECTOR_SET (result, 6, (long_to_integer (ts . year))); - FAST_VECTOR_SET (result, 7, (long_to_integer (ts . day_of_week))); - PRIMITIVE_RETURN (result); - } -} - DEFINE_PRIMITIVE ("ENCODED-TIME", Prim_encoded_time, 0, 0, "Return the current time as an integer.") { @@ -78,14 +48,16 @@ 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)") + #(TAG second minute hour day month year day-of-week dst)") { SCHEME_OBJECT vec; + unsigned int len; struct time_structure ts; PRIMITIVE_HEADER (1); vec = (VECTOR_ARG (1)); - if ((VECTOR_LENGTH (vec)) != 8) + len = (VECTOR_LENGTH (vec)); + if (! (len >= 8)) error_bad_range_arg (1); OS_decode_time (((time_t) (arg_integer (2))), &ts); FAST_VECTOR_SET (vec, 1, (long_to_integer (ts . second))); @@ -95,6 +67,8 @@ The vector's elements are:\n\ FAST_VECTOR_SET (vec, 5, (long_to_integer (ts . month))); FAST_VECTOR_SET (vec, 6, (long_to_integer (ts . year))); 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))); PRIMITIVE_RETURN (UNSPECIFIC); } @@ -102,20 +76,25 @@ DEFINE_PRIMITIVE ("ENCODE-TIME", Prim_encode_time, 1, 1, "Return the file time corresponding to the time structure given.") { SCHEME_OBJECT vec; + unsigned int len; struct time_structure ts; PRIMITIVE_HEADER (1); vec = (VECTOR_ARG (1)); - if ((VECTOR_LENGTH (vec)) != 8) + len = (VECTOR_LENGTH (vec)); + if (! (len >= 8)) error_bad_range_arg (1); - - ts.second = (integer_to_long (FAST_VECTOR_REF (vec, 1))); - ts.minute = (integer_to_long (FAST_VECTOR_REF (vec, 2))); - ts.hour = (integer_to_long (FAST_VECTOR_REF (vec, 3))); - ts.day = (integer_to_long (FAST_VECTOR_REF (vec, 4))); - ts.month = (integer_to_long (FAST_VECTOR_REF (vec, 5))); - ts.year = (integer_to_long (FAST_VECTOR_REF (vec, 6))); - ts.day_of_week = (integer_to_long (FAST_VECTOR_REF (vec, 7))); + (ts . second) = (integer_to_long (FAST_VECTOR_REF (vec, 1))); + (ts . minute) = (integer_to_long (FAST_VECTOR_REF (vec, 2))); + (ts . hour) = (integer_to_long (FAST_VECTOR_REF (vec, 3))); + (ts . day) = (integer_to_long (FAST_VECTOR_REF (vec, 4))); + (ts . month) = (integer_to_long (FAST_VECTOR_REF (vec, 5))); + (ts . year) = (integer_to_long (FAST_VECTOR_REF (vec, 6))); + (ts . day_of_week) = (integer_to_long (FAST_VECTOR_REF (vec, 7))); + (ts . daylight_savings_time) + = ((len > 8) + ? (integer_to_long (FAST_VECTOR_REF (vec, 8))) + : (-1)); PRIMITIVE_RETURN (long_to_integer ((long) (OS_encode_time (&ts)))); } diff --git a/v7/src/microcode/uxenv.c b/v7/src/microcode/uxenv.c index 9884d97ad..6645597df 100644 --- a/v7/src/microcode/uxenv.c +++ b/v7/src/microcode/uxenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: uxenv.c,v 1.12 1993/08/28 22:46:40 gjr Exp $ +$Id: uxenv.c,v 1.13 1995/04/23 03:04:58 cph Exp $ -Copyright (c) 1990-1993 Massachusetts Institute of Technology +Copyright (c) 1990-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -55,6 +55,7 @@ DEFUN (OS_decode_time, (t, buffer), time_t t AND struct time_structure * buffer) (buffer -> hour) = (ts -> tm_hour); (buffer -> minute) = (ts -> tm_min); (buffer -> second) = (ts -> tm_sec); + (buffer -> daylight_savings_time) = (ts -> tm_isdst); { /* In localtime() encoding, 0 is Sunday; in ours, it's Monday. */ int wday = (ts -> tm_wday); -- 2.25.1