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

Subject: RE: [xsl] current-dateTime() - no leading zero(s) before milliseconds
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 4 Jun 2008 16:16:54 +0100
> 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/

Current Thread