Return to BSD News archive
Received: by minnie.vk1xwt.ampr.org with NNTP id AA7216 ; Mon, 18 Jan 93 10:50:06 EST Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!yale.edu!yale!mintaka.lcs.mit.edu!ai-lab!hal.gnu.ai.mit.edu!mycroft From: mycroft@hal.gnu.ai.mit.edu (Charles Hannum) Newsgroups: comp.unix.bsd Subject: Re: problems with date Date: 19 Jan 1993 19:47:25 GMT Organization: /etc/organization Lines: 64 Message-ID: <1jhlsdINNno7@life.ai.mit.edu> References: <1iu2jsINN518@fbi-news.Informatik.Uni-Dortmund.DE> <1993Jan14.064517.7201@st.simbirsk.su> <1j4gfuINNpme@hrd769.brooks.af.mil> NNTP-Posting-Host: hal.gnu.ai.mit.edu I don't understand the point of the loop in clock.c. I think a better appropriate patch follows. Note that the line numbers are guaranteed to be wrong. (That's why we use context diffs, isn't it?) -----8<-----snip-----8<-----snip-----8<-----snip-----8<-----snip-----8<----- *** clock.c.orig Fri Nov 27 21:10:32 1992 --- clock.c Wed Jan 13 19:50:13 1993 *************** *** 59,62 **** --- 59,64 ---- #define DAYEN 303 + #define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) + startrtclock() { int s; *************** *** 95,104 **** unsigned long ret; ! ret = 0; y = y - 70; ! for(i=0;i<y;i++) { ! if (i % 4) ret += 365*24*60*60; ! else ret += 366*24*60*60; ! } ! return ret; } --- 126,132 ---- unsigned long ret; ! y -= 70; ! ret = (y*365) + ((y+1)/4) - ((y+69)/100) + ((y+369)/400); ! return (ret*24*60*60); } *************** *** 147,151 **** sec = bcd(rtcin(RTC_YEAR)); ! leap = !(sec % 4); sec += ytos(sec); /* year */ yd = mtos(bcd(rtcin(RTC_MONTH)),leap); sec += yd; /* month */ t = (bcd(rtcin(RTC_DAY))-1) * 24*60*60; sec += t; yd += t; /* date */ --- 175,179 ---- sec = bcd(rtcin(RTC_YEAR)); ! leap = isleap(sec); sec += ytos(sec); /* year */ yd = mtos(bcd(rtcin(RTC_MONTH)),leap); sec += yd; /* month */ t = (bcd(rtcin(RTC_DAY))-1) * 24*60*60; sec += t; yd += t; /* date */ *************** *** 154,158 **** sec += bcd(rtcin(RTC_MIN)) * 60; /* minutes */ sec += bcd(rtcin(RTC_SEC)); /* seconds */ - sec -= 24*60*60; /* XXX why ??? */ /* XXX off by one? Need to calculate DST on SUNDAY */ --- 182,185 ---- -----8<-----snip-----8<-----snip-----8<-----snip-----8<-----snip-----8<----- -- \ / Charles Hannum, mycroft@ai.mit.edu /\ \ PGP public key available on request. MIME, AMS, NextMail accepted. Scheme White heterosexual atheist male (WHAM) pride!