Calendar program not showing Father's Day

  • Thread starter Deleted member 3645
  • Start date
D

Deleted member 3645

Guest
Today in the US it is Father's Day, the 3rd Sunday in June.

I run the calendar program using a .calendar/calendar file containing only one line:
Code:
#include <calendar.usholiday>

Code:
$calendar
Jun 21* Summer Solstice

The output shows the Summer Solstice today, but does not show "Father's Day" as it should.

The calendar.usholiday file in /usr/share/calendar contains 42 lines including these:

Code:
06/SunThird  Father's Day (3rd Sunday of June)
06/21*  Summer Solstice

It looks like a bug. Is everyone having this bug?

I'm running FreeBSD 10.1 but have also seen this bug in the 9.2 version of calendar.
 
Here:
Code:
tingo@kg-core1$ uname -a
FreeBSD kg-core1.kg4.no 9.3-STABLE FreeBSD 9.3-STABLE #0 r273918: Fri Oct 31 22:52:44 CET 2014  root@kg-core1.kg4.no:/usr/obj/usr/src/sys/GENERIC  amd64

tingo@kg-core1$ calendar -f /usr/share/calendar/calendar.usholiday
Jun 21*   Summer Solstice

tingo@kg-core1$ egrep Father\|Solstice /usr/share/calendar/calendar.usholiday
06/SunThird   Father's Day (3rd Sunday of June)
06/21*   Summer Solstice
12/21*   Winter Solstice
HTH
 
I have a fix that works in this case and should work for all cases.

It is a patch to the /usr/src/usr.bin/calendar/parsedata.c file:

Code:
--- parsedata.c.orig 2014-11-11 12:03:24.000000000 -0800
+++ parsedata.c 2015-06-21 20:49:58.000000000 -0700
@@ -614,7 +614,7 @@
(F_MONTH | F_DAYOFWEEK | F_MODIFIERINDEX | F_VARIABLE)) {
offset = indextooffset(modifierindex);
dow = first_dayofweek_of_month(year, imonth);
- d = (idayofweek - dow + 8) % 7;
+ d = (7 + idayofweek - dow) % 7 + 1;

if (offset > 0) {
while (d <= yearinfo->monthdays[imonth]) {

After patching, make and make install of the calendar program I now get better results:

Code:
$calendar
Jun 21* Summer Solstice
Jun 21* Father's Day (3rd Sunday of June)
[CODE]
[/CODE]
 
There are several more places in the code where the day of the month is incorrectly calculated.

Additionally the variable dow can be -1 if the day of the week of the first day of the month is not in the current date tree.

If dow is -1 we simply want to return and do no further calculation.

Attached is a better patch. The spacing on this forum for code is not working...
 

Attachments

  • parsedata-fix.txt
    1.2 KB · Views: 272
Here:
Code:
tingo@kg-core1$ uname -a
FreeBSD kg-core1.kg4.no 9.3-STABLE FreeBSD 9.3-STABLE #0 r273918: Fri Oct 31 22:52:44 CET 2014  root@kg-core1.kg4.no:/usr/obj/usr/src/sys/GENERIC  amd64

tingo@kg-core1$ calendar -f /usr/share/calendar/calendar.usholiday
Jun 21*   Summer Solstice
Code:
Thanks for confirming the bug.
 
Back
Top