Division by zero in innreport
julien at trigofacile.com
Sat Jan 7 00:01:55 UTC 2012
>> There is an issue in how innreport translates these dates. The
>> ConvDate() function assumes the dates are relative to the *current*
>> year. So it thinks it has been passed Dec 31th 2012 and Jan 1st 2012
>> (whereas it was Dec 31th 2010 and Jan 1st 2011). As 2012 is a leap
>> year, and Dec 31th is after Feb 28th, the translated date contains an
>> unexpected "+1 day".
> This bug has been around for a long time. I think it may even be in Trac
> or TODO or somewhere, since I recall trying to fix it once and then
> getting too confused by the date parsing code and giving up.
I think you refer to:
The identified bug (counting the right number of days) was fixed but
another trickier one was introduced.
It is true that the date parsing code is confusing!
In the patch I attached to my previous mail, I make use of Time::Local
to convert dates to seconds since epoch, thus modifying the behaviour of
ConvDate() which was converting dates to seconds since January, 1st.
I bet innreport now runs slower, but I think it is better to achieve
robustness (the code using Time::Local seems easier to read and maintain).
In case you, Alexander or another reader here see improvements, do not
hesitate to tell.
I hope not to have introduced another bug.
At least, this patched version currently runs fine and generate a normal
HTML index page on my news server.
« Les ouvriers qui font la pause lentilles voient arriver un visiteur
inattendu… » (Astérix)
More information about the inn-workers