diffs for ctime.c for new DST rules, v7 systems
David Sherman
dave at lsuc.UUCP
Sun Feb 8 14:49:24 AEST 1987
(Note: this is cross-posted to several groups to increase its
chances of being seen by those who will want it. Followups are
directed to comp.bugs.misc.)
Both the U.S. and Canada (well, Ontario and at least some of the
other provinces) are adopting the new daylight savings time rules,
switching to DST the first Sunday in April instead of the last,
beginning in 1987. Below is a diff for /usr/src/libc/gen/ctime.c
for v7 systems; if you're running v7 you should be able to feed
this article right into "patch".
Once you make the change to ctime.c, anything which calls
ctime(3), localtime(3) or getdate(3) should be recompiled.
I've gone through the source on our system, and found all
the commands that call these routines.
To be absolutely correct for the future, all of these should be
recompiled after the ctime change is installed. Some of the
requirements are pretty minor, however; things like adb and awk
use ctime for diagnotic purposes only, I believe.
Here are the commands I'll be changing. This is under Perkin-Elmer
Edition VII Workbench. Other systems will differ; grep for
getdate, localtime and cdate through your source files.
/usr/src/cmd (basic v7 stuff):
make adb tp xsend spool/lpd awk learn uucp/* tar refer mail
ac at atrun calendar cron date ar find info iostat login ls
pr prof sa who write
/usr/src/ucb (stuff which came from Berkeley):
ex/exrecover snake daytime tod finger script ucbmail
/usr/sys/cmd (v7 and Berkeley stuff which is hardware-specific):
dmesg dump dumpdir fsck restor restor512 w
/usr/src/local (stuff off the net, etc.):
clock hdate logacct type whopast notes diff cpio news month
dumpdates last lastdown lastlog logcount lu talloc msgs
Now, to the ctime.c diffs:
The changed file will have #define NorthAm but not USA, which is
correct for Canada. If you are in the USA, add #define USA as well.
(The 1974-75 change didn't apply in Canada.)
(I also put in a minor speedup posted to the net a while back;
the test of year==74||year==75 is changed to year<=75&&year>=74,
which it a bit faster for dates between 1975 and 1987.)
Thanks to Mark Brader, {lsuc,sq}!msb, for the DST changes.
*** ctime.c.old Thu Mar 6 19:58:52 1986
--- ctime.c Sat Feb 7 21:13:55 1987
***************
*** 1,4
! #define USA
/*
#define Australia
*/
--- 1,4 -----
! #define NorthAm /* North America */
/*
#define USA
#define Australia
***************
*** 1,5
#define USA
/*
#define Australia
*/
--- 1,6 -----
#define NorthAm /* North America */
/*
+ #define USA
#define Australia
*/
***************
*** 26,31
*
* The routine calls the system to determine the local
* timezone and whether Daylight Saving Time is permitted locally.
#ifdef USA
* (DST is then determined by the current US standard rules)
* There is a table that accounts for the peculiarities
--- 27,34 -----
*
* The routine calls the system to determine the local
* timezone and whether Daylight Saving Time is permitted locally.
+ #ifdef NorthAm
+ * (DST is then determined by the current US and Canadian standard rules)
#ifdef USA
* There is a table that accounts for the peculiarities
* undergone by daylight time in 1974-1975.
***************
*** 27,33
* The routine calls the system to determine the local
* timezone and whether Daylight Saving Time is permitted locally.
#ifdef USA
- * (DST is then determined by the current US standard rules)
* There is a table that accounts for the peculiarities
* undergone by daylight time in 1974-1975.
#endif
--- 30,35 -----
#ifdef NorthAm
* (DST is then determined by the current US and Canadian standard rules)
#ifdef USA
* There is a table that accounts for the peculiarities
* undergone by daylight time in 1974-1975.
#endif
***************
*** 31,36
* There is a table that accounts for the peculiarities
* undergone by daylight time in 1974-1975.
#endif
#ifdef Australia
* (DST is then determined according to the Summer Time Act 1973 (Vic))
#endif
--- 33,39 -----
* There is a table that accounts for the peculiarities
* undergone by daylight time in 1974-1975.
#endif
+ #endif
#ifdef Australia
* (DST is then determined according to the Summer Time Act 1973 (Vic))
#endif
***************
*** 61,67
#define DS_GAP 1 /* DS time difference is 1 hour */
#endif
! #ifdef USA
/*
* daylight saving rules (copied from Bell original)
*/
--- 64,70 -----
#define DS_GAP 1 /* DS time difference is 1 hour */
#endif
! #ifdef NorthAm
/*
* daylight saving rules (copied from Bell original)
*/
***************
*** 66,72
* daylight saving rules (copied from Bell original)
*/
#define HEMI && /* northern hemisphere */
! #define DS_BEGIN 119 /* last possible start for DS, (last day in Apr) */
#define DS_END 303 /* last possible end day for DS, (last day in Oct) */
#define HOUR_ON 2 /* 2am - 3am is lost when DS starts */
#define HOUR_OFF 1 /* 1am - 2am runs twice when DS ends (??) */
--- 69,77 -----
* daylight saving rules (copied from Bell original)
*/
#define HEMI && /* northern hemisphere */
! #define DS_BEGIN 119 /* old last possible start for DS, (last day in Apr) */
! #define DS_NBEGIN 96 /* new last possible start for DS, (Apr 7) */
! /* (new rule begins in 1987) */
#define DS_END 303 /* last possible end day for DS, (last day in Oct) */
#define HOUR_ON 2 /* 2am - 3am is lost when DS starts */
#define HOUR_OFF 1 /* 1am - 2am runs twice when DS ends (??) */
***************
*** 140,145
dayno = ct->tm_yday;
daylbegin = DS_BEGIN;
daylend = DS_END;
#ifdef USA
if (ct->tm_year==74 || ct->tm_year==75) {
daylbegin = daytab[ct->tm_year-74].daylb;
--- 145,152 -----
dayno = ct->tm_yday;
daylbegin = DS_BEGIN;
daylend = DS_END;
+ #ifdef NorthAm
+ if (ct->tm_year >= 87) daylbegin = DS_NBEGIN;
#ifdef USA
else if (ct->tm_year<=75 && ct->tm_year>=74) {
daylbegin = daytab[ct->tm_year-74].daylb;
***************
*** 141,147
daylbegin = DS_BEGIN;
daylend = DS_END;
#ifdef USA
! if (ct->tm_year==74 || ct->tm_year==75) {
daylbegin = daytab[ct->tm_year-74].daylb;
daylend = daytab[ct->tm_year-74].dayle;
}
--- 148,154 -----
#ifdef NorthAm
if (ct->tm_year >= 87) daylbegin = DS_NBEGIN;
#ifdef USA
! else if (ct->tm_year<=75 && ct->tm_year>=74) {
daylbegin = daytab[ct->tm_year-74].daylb;
daylend = daytab[ct->tm_year-74].dayle;
}
***************
*** 145,150
daylbegin = daytab[ct->tm_year-74].daylb;
daylend = daytab[ct->tm_year-74].dayle;
}
#endif
daylbegin = sunday(ct, daylbegin);
daylend = sunday(ct, daylend);
--- 152,158 -----
daylbegin = daytab[ct->tm_year-74].daylb;
daylend = daytab[ct->tm_year-74].dayle;
}
+ #endif
#endif
daylbegin = sunday(ct, daylbegin);
daylend = sunday(ct, daylend);
David Sherman
The Law Society of Upper Canada
Toronto
--
{ seismo!mnetor cbosgd!utcs watmath decvax!utcsri ihnp4!utzoo } !lsuc!dave
More information about the Comp.unix.wizards
mailing list