# Calendar program not showing Father's Day



## Deleted member 3645 (Jun 21, 2015)

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:

```
#include <calendar.usholiday>
```


```
$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:


```
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.


----------



## tingo (Jun 21, 2015)

Here:

```
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


----------



## Deleted member 3645 (Jun 22, 2015)

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:


```
--- 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:


```
$calendar
Jun 21* Summer Solstice
Jun 21* Father's Day (3rd Sunday of June)
[CODE]
```
[/CODE]


----------



## Deleted member 3645 (Jun 22, 2015)

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...


----------



## Deleted member 3645 (Jun 22, 2015)

tingo said:


> Here:
> 
> ```
> tingo@kg-core1$ uname -a
> ...




```
Thanks for confirming the bug.
```


----------



## drhowarddrfine (Jun 22, 2015)

No one thinks of Father's Day.... *sniff*


----------



## junovitch@ (Jun 22, 2015)

Submit a PR:  https://bugs.FreeBSD.org/bugzilla/


----------



## Deleted member 3645 (Jun 25, 2015)

junovitch said:


> Submit a PR:  https://bugs.FreeBSD.org/bugzilla/



Yes, I created  bug 201062
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201062


----------

