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 359246 - date:seconds returns incorrect value around start of month
date:seconds returns incorrect value around start of month
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other Windows
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-10-03 11:45 UTC by Christopher R. Palmer
Modified: 2006-10-12 15:15 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Christopher R. Palmer 2006-10-03 11:45:43 UTC
It appears that the code that computes the current datetime in libexslt/date.c is incorrectly computing the current timezone offset around month boundaries.  Specifically, when I am in EDT and my localtime is in September and GMT is in October, it returns a time that is incorrect by more than 24 hours.  Here is the posting I sent to the mailing list which includes specific instructions for reproducing the problem.

On Sun, Oct 01, 2006 at 08:07:57AM -0400, Christopher R. Palmer wrote:
> > Last night, date:seconds() started returning invalid values. To test I 
> > created a simple stylesheet that simply printed
> > 
> > <xsl:value-of select="date:seconds()"/>
> > 
> > It printed a time from the day before.  Coincidentally, this started 
> > happening after 8pm EDT which would be when my time was in September and 
> > the GM time was in October.  The code (line 791 of 1.1.17) looks pretty 
> > suspicious to me:
> > 
> >      ret->value.date.tzo = (((ret->value.date.day * 1440) +
> >                              (ret->value.date.hour * 60) +
> >                               ret->value.date.min) -
> >                             ((gmTm->tm_mday * 1440) + (gmTm->tm_hour * 60) +
> >                               gmTm->tm_min));
> > 
> > which seems to be computing the seconds between localtime and gmtime.  With 
> > no mention of month I can't see how that is right...  I assume something 
> > similar but worse will happen at the end of the year.
> > 
> > I can reproduce this problem by adding
> > 
> > secs = 1159664596;
> > 
> > immediately after the call to time(NULL) in exsltDateCurrent while running 
> > the software on a machine in EDT.  When I do this, the value of tzo is 2000 
> > while the correct value should be -240.
Comment 1 William M. Brack 2006-10-12 15:15:21 UTC
I would agree that the code you point out is somewhat less than accurate.  I have replaced it with a call to the library function "mktime" which, I think, should take care of all the horrible, messy details of end-of-month problems.  The new code is in CVS.