After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 760576 - NETWORKDAYS is broken
NETWORKDAYS is broken
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: General
git master
Other Linux
: Normal normal
: ---
Assigned To: Andreas J. Guelzow
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2016-01-13 13:19 UTC by Morten Welinder
Modified: 2016-01-16 08:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Morten Welinder 2016-01-13 13:19:12 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;
Comment 1 Andreas J. Guelzow 2016-01-13 16:19:17 UTC
This also appears to assume that every serial number is a valid date. '60' is not.
Comment 2 Andreas J. Guelzow 2016-01-14 07:09:02 UTC
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!
Comment 3 Morten Welinder 2016-01-14 12:31:37 UTC
We could refuse to work before 1900/3/1.  That's really not important.
Comment 4 Andreas J. Guelzow 2016-01-16 08:08:55 UTC
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.