Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Apr 1999 22:13:47 -0700 (PDT)
From:      jobaldwi@vt.edu
To:        freebsd-gnats-submit@freebsd.org
Subject:   bin/11399: Calendar doesn't always handle 'last' days right...
Message-ID:  <19990430051347.CE1E5152D7@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         11399
>Category:       bin
>Synopsis:       Calendar doesn't always handle 'last' days right...
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 29 22:20:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     John Baldwin
>Release:        3.1-STABLE
>Organization:
>Environment:
FreeBSD john.baldwin.cx 3.1-STABLE FreeBSD 3.1-STABLE #15: Mon Apr 19 22:48:08 EDT 1999     root@john.baldwin.cx:/usr/source/src/sys/compile/JOHN  i386
>Description:
For days that are specified as the last weekday of the month, calendar
can sometimes choke and extend the length of a month and have the specified
event mentioned one week late.  See the example below for this to make sense.
>How-To-Repeat:
> calendar -f /usr/share/calendar/calendar.holiday -t 30.4
Apr 33* Arbor Day in Wyoming (last Monday)
Apr 33* Confederate Memorial Day in Alabama & Mississippi (last Monday)

April dosen't have 33 days, and the days above should be 26, not 33.
Note that this only fails on April 30, it works for every other day.

>Fix:
Here's an ugly hack that ignores days whose dates are greater than the
number of days in the month for these types of day specifications, but
someone who understands all of the math and whatnot should figure out
why it is generating 33 instead of 26 for the day.

RCS file: /usr/cvs/src/usr.bin/calendar/day.c,v
retrieving revision 1.11
diff -u -r1.11 day.c
--- day.c       1997/10/26 12:51:30     1.11
+++ day.c       1999/04/30 05:13:06
@@ -325,8 +325,9 @@
                    v2 = tp->tm_mday + (((day - 1) - tp->tm_wday + 7) % 7);
 
                    /* (month length - day) / 7 + 1 */
-                   if (((int)((cumdays[month+1] - 
-                              cumdays[month] - v2) / 7) + 1) == -v1)
+                   if ((((int)((cumdays[month+1] - 
+                              cumdays[month] - v2) / 7) + 1) == -v1) &&
+                       (v2 <= cumdays[month+1] - cumdays[month]))
                        /* bingo ! */
                        day = v2;
                    


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990430051347.CE1E5152D7>