Re: [xslt] Troubles with the EXSLT date extensions
- From: cbozeman hiwaay net
- To: xslt gnome org
- Subject: Re: [xslt] Troubles with the EXSLT date extensions
- Date: Wed, 18 Sep 2002 08:24:07 -0500 (CDT)
Igor,
Your fixes are fine, lets go with them. If you would, could you fix the header
comment for _exsltDateDifference to reflect the algorithm is y - x. The
attachment is a patch for difference.1.xml (this may be the one I sent yesterday
but I am not sure).
Note to Daniel:
difference.1.out and seconds.1.out need to be regenerated because I had
implemented the difference function backwards.
Thanks for taking care of this.
Charlie B.
Quoting Igor Zlatkovic <igor@stud.fh-frankfurt.de>:
> > Doh! I implemented difference backwards. I should have been
> subtracting
> y - x
> > (like you did). This means that the seconds function is also wrong.
> > However, I was trying to show that it is still possible for multiple
> items
> in
> > the duration object to have negative values which the format function
> will
> not
> > handle correctly (i.e. embedded '-' in the output string). See the
> new
> patch for
> > an example.
>
> Aaaaaaa... aaa... may the Lord strike me awake, that embedded '-' has
> escaped my attention. No, embedding a '-' is not an acceptable act, not
> for
> a duration format function :-)
>
> > I'll start making changes.
>
> Eh? Does that mean you wish to fix the format function? Okay with me. I
> have
> also done so, but yours is the baby :-)
>
> I saw just after realising the existence of that embedded '-' that the
> format function calls xmlXPathCastNumberToString(), and that means that
> it
> may never pass it a negative argument. I then thought about ensuring
> that
> all possible arguments to the XPath function are positive. You think
> this is
> okay?
>
> Ciao
> Igor
>
>
> RCS file: /cvs/gnome/libxslt/libexslt/date.c,v
> retrieving revision 1.15
> diff -c -r1.15 date.c
> *** date.c 17 Sep 2002 16:13:44 -0000 1.15
> --- date.c 18 Sep 2002 10:15:25 -0000
> ***************
> *** 1058,1076 ****
> years = (double)(dt->mon / 12);
> months = (double)(dt->mon % 12);
>
> if (secs < 0.0) {
> secs = -secs;
> ! *cur++ = '-';
> ! } else if (days < 0) {
> days = -days;
> ! *cur++ = '-';
> ! } else if (years < 0) {
> years = -years;
> ! *cur++ = '-';
> ! } else if (months < 0) {
> months = -months;
> ! *cur++ = '-';
> }
>
> *cur++ = 'P';
>
> --- 1058,1082 ----
> years = (double)(dt->mon / 12);
> months = (double)(dt->mon % 12);
>
> + *cur = '\0';
> if (secs < 0.0) {
> secs = -secs;
> ! *cur = '-';
> ! }
> ! if (days < 0) {
> days = -days;
> ! *cur = '-';
> ! }
> ! if (years < 0) {
> years = -years;
> ! *cur = '-';
> ! }
> ! if (months < 0) {
> months = -months;
> ! *cur = '-';
> }
> + if (*cur == '-')
> + cur++;
>
> *cur++ = 'P';
>
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt@gnome.org
> http://mail.gnome.org/mailman/listinfo/xslt
>
difference.1.xml-pat
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]