home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / fj / os / 386bsd / 228 < prev    next >
Encoding:
Internet Message Format  |  1993-01-02  |  3.7 KB

  1. Path: sparky!uunet!ccut!news.u-tokyo.ac.jp!yayoi!tansei1!mhiroshi
  2. From: mhiroshi@tansei.cc.u-tokyo.ac.jp (H. Murakami)
  3. Newsgroups: fj.os.386bsd
  4. Subject: Fix for the date bug 1993.
  5. Message-ID: <3811@tansei1.tansei.cc.u-tokyo.ac.jp>
  6. Date: 2 Jan 93 06:46:18 GMT
  7. Sender: news@tansei.cc.u-tokyo.ac.jp
  8. Distribution: fj
  9. Organization: Hokkaido Univ. However I am subject to tansei for JUNET.
  10. Lines: 105
  11.  
  12. To: fj.os.386bsd
  13. Subject: Fix for the date bug.
  14.  
  15. $B1<G/4XO"$N%"%k%4%j%:%`$N8m$j$K$h$j(J1993$BG/$+$i;~7W$NF|IU$,68$&(J .
  16. $B0J2<$N(J $B%P%0(JFIX patch $B$r(J i386/isa/clock.c  $B$KEv$F$F$/$@$5$$(J.
  17.  
  18. (PC98$BHG$O$I$&$@$m$&(J?)
  19. -------------------------------------------------------------------------------
  20.                          $BJbJbJbJbJbJbJbJbJb(J              $BB<>e(J   $B90(J
  21. PPPPPPPP                   $B3Q(J          $BHt(J
  22. RNBQKBNR                 $B9a7K6d6b6L6b6d7K9a(J   mhiroshi@tansei.cc.u-tokyo.ac.jp
  23.  
  24. =======> QUOTE FOLLOWS <===========
  25. From: ache@astral.msk.su (Andrew A. Chernov, Black Mage)
  26. Newsgroups: comp.unix.bsd
  27. Subject: [386bsd] New Year patch for CMOS clock, was still 92 year
  28. Message-ID: <DG5x0Hha50@astral.msk.su>
  29. Date: 1 Jan 93 09:28:37 GMT
  30. Sender: news-service@newcom.kiae.su
  31. Reply-To: ache@astral.msk.su
  32. Organization: Ha-oh-lahm Yetzirah
  33. Lines: 79
  34. Status: R
  35.  
  36. Hi,
  37. I look today at my computer and see, that still 92 year now active :-(
  38. Here is a patch to fix it (I was mathematician and remember,
  39. that (y % 4) operation need whole year instead of (y - 1970),
  40. moreover (y % 4) determinition of leap year is wrong,
  41. see #define isleap() below for correct implementation).
  42. This patch fix another small problem too, old code add 9x additional
  43. seconds in any case: (sec += ytos(sec) instead of sec = ytos(sec))
  44.  
  45. P.S.: Happy New Year!
  46.  
  47. *** clock.c.was    Sun Nov 22 02:52:30 1992
  48. --- clock.c    Fri Jan  1 12:17:04 1993
  49. ***************
  50. *** 58,63 ****
  51. --- 58,65 ----
  52.   #define DAYST 119
  53.   #define DAYEN 303
  54.   
  55. + #define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
  56.   startrtclock() {
  57.       int s;
  58.   
  59. ***************
  60. *** 94,102 ****
  61.       int i;
  62.       unsigned long ret;
  63.   
  64. !     ret = 0; y = y - 70;
  65. !     for(i=0;i<y;i++) {
  66. !         if (i % 4) ret += 365*24*60*60;
  67.           else ret += 366*24*60*60;
  68.       }
  69.       return ret;
  70. --- 96,104 ----
  71.       int i;
  72.       unsigned long ret;
  73.   
  74. !     ret = 0;
  75. !     for(i=1970;i<y;i++) {
  76. !         if (!isleap(i)) ret += 365*24*60*60;
  77.           else ret += 366*24*60*60;
  78.       }
  79.       return ret;
  80. ***************
  81. *** 145,152 ****
  82.       while ((sa&RTCSA_TUP) == RTCSA_TUP)
  83.           sa = rtcin(RTC_STATUSA);
  84.   
  85. !     sec = bcd(rtcin(RTC_YEAR));
  86. !     leap = !(sec % 4); sec += ytos(sec); /* year    */
  87.       yd = mtos(bcd(rtcin(RTC_MONTH)),leap); sec += yd;    /* month   */
  88.       t = (bcd(rtcin(RTC_DAY))-1) * 24*60*60; sec += t; yd += t; /* date    */
  89.       day_week = rtcin(RTC_WDAY);                /* day     */
  90. --- 147,154 ----
  91.       while ((sa&RTCSA_TUP) == RTCSA_TUP)
  92.           sa = rtcin(RTC_STATUSA);
  93.   
  94. !     t = bcd(rtcin(RTC_YEAR)) + 1900;
  95. !     leap = isleap(t); sec = ytos(t); /* year    */
  96.       yd = mtos(bcd(rtcin(RTC_MONTH)),leap); sec += yd;    /* month   */
  97.       t = (bcd(rtcin(RTC_DAY))-1) * 24*60*60; sec += t; yd += t; /* date    */
  98.       day_week = rtcin(RTC_WDAY);                /* day     */
  99. ***************
  100. *** 153,159 ****
  101.       sec += bcd(rtcin(RTC_HRS)) * 60*60;            /* hour    */
  102.       sec += bcd(rtcin(RTC_MIN)) * 60;            /* minutes */
  103.       sec += bcd(rtcin(RTC_SEC));                /* seconds */
  104. -     sec -= 24*60*60; /* XXX why ??? */
  105.   
  106.       /* XXX off by one? Need to calculate DST on SUNDAY */
  107.       /* Perhaps we should have the RTC hold GMT time to save */
  108. --- 155,160 ----
  109. -- 
  110. In-This-Life:  Andrew A. Chernov    |  "Hay mas dicha, mas contento
  111. Internet:      ache@astral.msk.su   |  "Que adorar una hermosura
  112. Organization:  The RELCOM Corp.,    |  "Brujuleada entre los lejos
  113.                Moscow, Russia       |  "De lo imposible?!"  (Calderon)
  114.  
  115.  
  116.