Subject: bug#43677: 27.1; Calc holidays off-by-one error, incorrect business day calculation

From: Mattias Engdegård <[email-masked]>
Date: Wed, 30 Sep 2020 11:42:58 +0200

> Indeed -- applying the following patch (which numbers Monday as 0 and Sunday as 6) makes the test case work correctly for me. But trying to follow the code makes it unclear... er... what's going on, and there aren't many comments in the Calc code to explain what they were thinking.

Welcome to Calc!

> I wondered whether this might be a US/non-US thing (with a difference in what day starts the week), but I couldn't really find anything in calc talking about that... 

The weekday numbering can be arbitrary as long as it is only used internally. Calc's date representation (from Rata Die) sets Dec 31, 1 B.C. as day 0, and this happens to be a Sunday. That means that (mod DAY 7) is an easy way to get the week-starts-on-Sunday numbering used by some foreigners.

Since the bug is a regression -- it is present in Emacs 26.1 but not in 22.1.1 -- it may be a good idea to find out exactly what change introduced it, and work from there. That might reduce the risk of causing secondary bugs.