problem in dt_setdoe
Chuck Hagenbuch
chuck@horde.org
Tue, 5 Dec 2000 19:31:53 -0500
In the course of playing with Kronolith (my php web calendar written using
mcal), I noticed that no repeating events were showing up in the last week of
December. Thinking this odd, I started digging, and (after groaning at a lot
of "// I have no idea how this works" comments in the source) found that
dt_setdoe has a bug: it skips the 31st of December this year.
If you pass in 730484, you get back a datetime_t with December 30th, 2000 in
it. If you pass in 730485, you get a datetime_t with January 1st, 2001.
However, now I'm stuck, since I can't find any documentation on algorithms for
days-since-epoch on the net, and the code in question:
year = 400 * (doe / (400 * 365 + 97)); doe %= (400 * 365 + 97);
year += 100 * (doe / (100 * 365 + 24)); doe %= (100 * 365 + 24);
year += 4 * (doe / (4 * 365 + 1)); doe %= (4 * 365 + 1);
year += (doe / 365) + 1; doe %= 365;
... is a chunk of math that I don't even want to _try_ messing with by trial
and error.
Btw, the circumstances under which I reproduced this problem involve using
Monday as the start of the week (which is the ISO standard, btw), so remember
to change that if you try and reproduce it holistically.
Also, I have a request: anyone who fixes this, please mail me the fix and let
me commit it. In the course of tracking this down, I cleaned up a lot of random
cruft and added some comments to the source explaining some of the more
unintuitive bits (though there's certainly a lot left to do in that regard),
and I'd like not to have to merge those changes in to another commit.
Finally: I asked a few weeks ago about cutting a new release of the library,
since the last time a tarball was released was March. If no one who is
currently a project admin on Sourceforge has the time/interest to do releases
(preferably once this bug is fixed), would you be willing to make me a project
admin (Mark?)? I already have dev access to the project; my Sourceforge userid
is "chuck".
Thanks,
-chuck
--
Charles Hagenbuch, <chuck@horde.org>
"If you can't stand the heat, get out of the chicken!" - Baby Blues