Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Jun 2015 23:58:48 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 201062] Calendar did not show Father's day on June 22, 2015 using calendar.usholiday
Message-ID:  <bug-201062-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201062

            Bug ID: 201062
           Summary: Calendar did not show Father's day on June 22, 2015
                    using calendar.usholiday
           Product: Base System
           Version: 10.1-STABLE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: comet.berkeley@gmail.com

Created attachment 158000
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=158000&action=edit
Calendar Father's Day patch

The calendar.usholiday file contains 42 lines of which 2 are relevant to June
21, 2015:
06/SunThird     Father's Day (3rd Sunday of June)
06/21*  Summer Solstice

My .calendar/calendar file includes this one line:
#include <calendar.usholiday>

And when calendar runs it should show two lines out, one for Father's Day and
one for the Solstice:

$calendar -t21.6.2015
Jun 21* Summer Solstice

I patched the code (calendar.c and parsedata.c) and the problem seems to be
fixed.

$calendar -t21.6.2015
Jun 21* Summer Solstice
Jun 21* Father's Day (3rd Sunday of June)

To debug this it was helpful to set the debug_remember flag in
the dates.c code.  This flag is a global integer and can be set from calendar.c
when the -d option (debug) is set.

In parsedata.c, the calculation of the first day of the recurring weekdays is
wrong as it is trying to calculate a day of the month but will always return an
integer in the range 0-6.  0 is always wrong...

It was:
    d = (idayofweek - dow + 8) % 7;

But should be:
    d = (idayofweek - dow + 7) % 7 + 1;  

Additionally the variable dow can be -1 and when it is the code should probably
stop (continue) so a better patch is this:

    if (dow < 0)
        continue;
    d = (idayofweek - dow + 7) % 7 + 1;

-- 
You are receiving this mail because:
You are the assignee for the bug.



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