[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: current-dateTime() - no leading zero(s) before mi

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.