[exslt] Corrections to the date.msxsl.xsl module
Bruce Rindahl
rindahl at lrcwe.com
Thu Jun 16 12:33:31 MDT 2005
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.
Hope this helps!
Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fourthought.com/pipermail/exslt/attachments/20050616/a1b4f64a/attachment.htm
More information about the exslt
mailing list