Re: Corrections to the date.msxsl.xsl module
James Fuller <[email protected]>
| Newsgroups | gmane.text.xml.xslt.extensions |
|---|---|
| Organization | Webcomposite |
| Message-ID | <[email protected]> |
Bruce Rindahl wrote:
> To everyone using the dates-times module in IE there is a bug in the
> date:seconds module.
>
> The old code is:
>
>
>
> function seconds(){//
>
> if (arguments.length > 0){
>
> var oDate;
>
> if ((oDate = _validDate(arguments[0],
> "xs:dateTime")) ||
>
> (oDate = _validDate(arguments[0],
> "xs:date")) ||
>
> (oDate = _validDate(arguments[0],
> "xs:gYearMonth")) ||
>
> (oDate = _validDate(arguments[0],
> "xs:gYear"))
>
> )
>
> return oDate.valueOf()/1000;
>
> else
>
> if (oDate =
> _validDuration(arguments[0]))
>
> return oDate.Seconds();
>
> else
>
> return Number.NaN;
>
> }else
>
> return Math.floor(new
> Date().valueOf()/1000);//current local date/time
>
> }
>
>
>
> The correct code should be:
>
>
>
> function seconds(){//
>
> if (arguments.length > 0){
>
> var oDate;
>
> if ((oDate = _validDate(arguments[0],
> "xs:dateTime")) ||
>
> (oDate = _validDate(arguments[0],
> "xs:date")) ||
>
> (oDate = _validDate(arguments[0],
> "xs:gYearMonth")) ||
>
> (oDate = _validDate(arguments[0],
> "xs:gYear"))
>
> )
>
> return oDate.valueOf()/1000;
>
> else
>
> if (oDate =
> _validDuration(arguments[0]))
>
> if
> (arguments[0].charAt(0) != '-')
>
> return
> oDate.Seconds()/1000;
>
> else
>
> return
> oDate.Seconds()/(-1000);
>
>
>
> else
>
> return Number.NaN;
>
> }else
>
> return Math.floor(new
> Date().valueOf()/1000);//current local date/time
>
> }
>
>
>
> This corrects two bugs. The first is the function returned the value
> in milliseconds if you called it with a duration value. The second is
> the function always returned a positive value even with a negative
> duration. Both of these are corrected with the code above.
>
thx for this, just putting finishing touches on new exslt distro, will
fold this in today.
cheers, Jim Fuller
>
>
> Hope this helps!
>
>
>
> Bruce
>
>------------------------------------------------------------------------
>
>_______________________________________________
>exslt mailing list
>[email protected]
>http://www.exslt.org/list
>