Re: [xslt] Troubles with the EXSLT date extensions



Damn... my server picked up your mail two seconds after I have sent my
messaege :-)

I did something different, but have changed exactly the same place. The diff
for my changes follows this message. I basically simply adjusted the day and
sec, based on the sign difference between day and sec. The thing is simple,
because sec cannot contain anything greater than SECS_PER_DAY at that place.
I also swapped the places of x and y, to get rid of the wrong sign problem.
Have a look. You think that is somewhere near okay?

Ciao
Igor


RCS file: /cvs/gnome/libxslt/libexslt/date.c,v
retrieving revision 1.14
diff -c -r1.14 date.c
*** date.c      30 May 2002 21:36:57 -0000      1.14
--- date.c      17 Sep 2002 16:11:48 -0000
***************
*** 1587,1599 ****

      if (((x->type == XS_GYEAR) || (x->type == XS_GYEARMONTH)) && (!flag))
{
          /* compute the difference in months */
!         ret->value.dur.mon = ((x->value.date.year * 12) +
x->value.date.mon) -
!                              ((y->value.date.year * 12) +
y->value.date.mon);
      } else {
!         ret->value.dur.day  = _exsltDateCastYMToDays(x) -
!                               _exsltDateCastYMToDays(y);
!         ret->value.dur.day += x->value.date.day - y->value.date.day;
!         ret->value.dur.sec  = TIME_TO_NUMBER(x) - TIME_TO_NUMBER(y);
      }

      return ret;
--- 1587,1608 ----

      if (((x->type == XS_GYEAR) || (x->type == XS_GYEARMONTH)) && (!flag))
{
          /* compute the difference in months */
!         ret->value.dur.mon = ((y->value.date.year * 12) +
y->value.date.mon) -
!                              ((x->value.date.year * 12) +
x->value.date.mon);
!       /* The above will give a wrong result if x and y are on different
sides
!        of the September 1752. Resolution is welcome :-) */
      } else {
!         ret->value.dur.day  = _exsltDateCastYMToDays(y) -
!                               _exsltDateCastYMToDays(x);
!         ret->value.dur.day += y->value.date.day - x->value.date.day;
!         ret->value.dur.sec  = TIME_TO_NUMBER(y) - TIME_TO_NUMBER(x);
!       if (ret->value.dur.day > 0.0 && ret->value.dur.sec < 0.0) {
!           ret->value.dur.day -= 1;
!           ret->value.dur.sec = ret->value.dur.sec + SECS_PER_DAY;
!       } else if (ret->value.dur.day < 0.0 && ret->value.dur.sec > 0.0) {
!           ret->value.dur.day += 1;
!           ret->value.dur.sec = ret->value.dur.sec - SECS_PER_DAY;
!       }
      }

      return ret;








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]