home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / trn36-2.zip / leapyear.p next >
Internet Message Format  |  1996-01-11  |  2KB

  1. From news.space.net!news.ecrc.de!news.sprintlink.net!nntp.coast.net!news.net99.net!news.crosslink.net!not-for-mail 8 Jan 1996 20:57:14 -0000
  2. Path: news.space.net!news.ecrc.de!news.sprintlink.net!nntp.coast.net!news.net99.net!news.crosslink.net!not-for-mail
  3. From: shields@crosslink.net (Michael Shields)
  4. Newsgroups: comp.sources.bugs
  5. Subject: Re: trn 3.6 leap year bug (unofficial patch)
  6. Date: 8 Jan 1996 20:57:14 -0000
  7. Organization: CrossLink Internet Access and Networking Services
  8. Lines: 53
  9. Message-ID: <4cs0fa$ui9@hermes.crosslink.net>
  10. References: <4chi8v$6h5@solutions.solon.com>
  11. NNTP-Posting-Host: hermes.crosslink.net
  12.  
  13. In article <4chi8v$6h5@solutions.solon.com>,
  14. Peter Seebach <seebs@solutions.solon.com> wrote:
  15. > !     /* This simple algorithm will be valid until the year 2099 */
  16.  
  17. Might as well plan for the long term.
  18.  
  19. Index: nntp.c
  20. ===================================================================
  21. RCS file: /usr/local/src/master/trn/nntp.c,v
  22. retrieving revision 1.1.1.1
  23. diff -c -r1.1.1.1 nntp.c
  24. *** 1.1.1.1    1995/12/28 18:18:40
  25. --- nntp.c    1996/01/08 20:50:49
  26. ***************
  27. *** 306,320 ****
  28.       s[4] = '\0';
  29.       year = atoi(s);
  30.   
  31. !     /* This simple algorithm will be valid until the year 2400 */
  32. !     if (year % 4)
  33.       maxdays[2] = 28;
  34. !     else
  35.       maxdays[2] = 29;
  36.       if (month < 1 || month > 12 || day < 1 || day > maxdays[month]
  37.        || hh < 0 || hh > 23 || mm < 0 || mm > 59
  38.        || ss < 0 || ss > 59)
  39.       return time((time_t*)NULL);
  40.   
  41.       for (month--; month; month--)
  42.       day += maxdays[month];
  43. --- 306,325 ----
  44.       s[4] = '\0';
  45.       year = atoi(s);
  46.   
  47. !     maxdays[2] = 28;
  48. !     if (year % 4 == 0)
  49. !     maxdays[2] = 29;
  50. !     if (year % 100 == 0)
  51.       maxdays[2] = 28;
  52. !     if (year % 400 == 0)
  53.       maxdays[2] = 29;
  54.       if (month < 1 || month > 12 || day < 1 || day > maxdays[month]
  55.        || hh < 0 || hh > 23 || mm < 0 || mm > 59
  56.        || ss < 0 || ss > 59)
  57.       return time((time_t*)NULL);
  58. +     if (maxdays[2] == 29 && month < 3)
  59. +     --day; /* kluge to allow for the below */
  60.   
  61.       for (month--; month; month--)
  62.       day += maxdays[month];
  63. -- 
  64. Shields, CrossLink.
  65.  
  66.