After retrying the code after noticing the comment about May being wrong, here's some code that seems to work much better:
replace this block of code (from the original javascript code):
startspaces = thisdate;
while (startspaces > 7) {
startspaces -= 7;
startspaces = thisday - startspaces + 1;
}
if (startspaces < 0) {
startspaces += 7;
}
with this single line of code:
startspaces = thisday;
Note that I use thisday
and not thisdate
here.
This seems to work for all of 2009.
Lasse V. Karlsen
2009-04-28 15:09:33