Corrections to the date.msxsl.xsl module

"Bruce Rindahl" <[email protected]>
Newsgroups gmane.text.xml.xslt.extensions
Organization Leonard Rice Engineers, Inc.
Message-ID <000d01c572a1$e5afc510$1700a8c0@BRUCE>
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

_______________________________________________
exslt mailing list
[email protected]
http://www.exslt.org/list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.