GNOME Bugzilla – Bug 760576
NETWORKDAYS is broken
Last modified: 2016-01-16 08:08:55 UTC
We have... weekday = g_date_get_weekday (&start_date); [...] for (i = start_serial; i <= end_serial; i++) { if (!weekends[weekday]) res++; weekday = (weekday + 1) % 7; } Notice how the last assignment and the array lookup uses 0..6 for weekday. If I read things right, 0 is Sunday. But g_date_get_weekday gives us 1-7 with 7 being Sunday. typedef enum { G_DATE_BAD_WEEKDAY = 0, G_DATE_MONDAY = 1, G_DATE_TUESDAY = 2, G_DATE_WEDNESDAY = 3, G_DATE_THURSDAY = 4, G_DATE_FRIDAY = 5, G_DATE_SATURDAY = 6, G_DATE_SUNDAY = 7 } GDateWeekday;
This also appears to assume that every serial number is a valid date. '60' is not.
The current code makes some bad assumptions. For example if the range contains the day between 1900/2/28 and 1900/3/1 it just decreases the endserial date. That would work if we didn't have the holiday array since the endserial date might be a holiday. We need to be much more careful!
We could refuse to work before 1900/3/1. That's really not important.
This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.