xsl-list
[Top] [All Lists]

RE: [xsl] current-dateTime() - no leading zero(s) before milliseconds

2008-06-04 08:17:24
and also tried this in Saxon - several times

2008-06-04T18:31:51.8+04:00 (one digit, no leading zeros 
after dot - bad for me) 

A leading zero would change the meaning. 51.8 means 51 seconds and 800
milliseconds, 51.08 would mean 51 seocnds and 80 milliseconds. There are no
trailing zeros in Saxon's output because the canonical lexical
representation of a date/time value doesn't allow them.


well, in one xslt i calculate timestamp by <xsl:param name="timestamp"
        
select="translate(substring(string(current-dateTime()), 1, 
23), 'T:-.','')"/>

i need 3 digit from milliseconds with leading zeros

how can i avoid this strange effect?


Don't try to manipulate the values as strings. To get the number of seconds
(as a number), use seconds-from-dateTime(current-dateTime); if you only want
the fractional part, use ($secs mod 1.0); if you want that as a number of
milliseconds, multiply it by 1000; if you want the number of millseconds as
an integer, apply one of the rounding functions.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>