*BSD News Article 25580


Return to BSD News archive

Newsgroups: comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!elroy.jpl.nasa.gov!decwrl!netcomsv!netcom.com!fen
From: fen@netcom.com (Fen Labalme)
Subject: bug fix for NetBSD calendar
Message-ID: <fenCJ4oDs.19v@netcom.com>
Organization: NETCOM On-line Communication Services (408 241-9760 guest)
X-Newsreader: TIN [version 1.2 PL1]
Date: Tue, 4 Jan 1994 23:10:39 GMT
Lines: 35

Well, it's the new year, and I discovered a bug in setting up my calendar(1).
The days seemed to be off by one, and I think I've fixed the problem.
The diff is below:

% diff calendar.c.~1~ calendar.c
*** calendar.c.~1~      Tue Jan  4 11:48:24 1994
--- calendar.c  Tue Jan  4 14:40:58 1994
***************
*** 139,144 ****
  /* 1-based month, 0-based days, cumulative */
  int daytab[][14] = {
!       0, 0, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364,
!       0, 0, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365,
  };
  struct tm *tp;
--- 139,144 ----
  /* 1-based month, 0-based days, cumulative */
  int daytab[][14] = {
!       0, -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364,
!       0, -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365,
  };
  struct tm *tp;

=====

Since January 1 is the 0'th day, adding 1 to -1 returns the correct value.
The rest of the daytab[][] appears correct.

Enjoy!
Fen
-- 
Fen Labalme                for EFF info,  email <eff@eff.org>
Broadcatch Technologies    for LPF info,  email <league@ai.mit.edu>
<fen@netcom.com>           for CPSR info, email <cpsr@cpsr.org>
415/731-1174               protect your freedoms!  PGP Key ID: 1024/0AF8FD