This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: format-number and time or ???
- To: xsl-list at mulberrytech dot com
- Subject: Re: format-number and time or ???
- From: David_Marston at lotus dot com
- Date: Fri, 10 Nov 2000 11:14:48 -0500
- Reply-To: xsl-list at mulberrytech dot com
Robert Koberg asks:
>First is there a better function to use than format-number when trying
>to make numbers look like:
>02:59:12
>hours:minutes:seconds
I think format-number works well, but you have to think about it in
a different way. The format-number function is designed to render one
rational number in base 10 without scientific notation. Crucial to
your need is that it will only do one stream of leading zeroes.
Thus, you need to render three numbers (hours, minutes, seconds)
in succession, with slightly different formats for each.
The overall string would be produced by this formula, which could be
used in an xsl:value-of instruction:
concat(format-number($hours,'#0'),':',
format-number($minutes,'00'),':',
format-number($seconds,'00.###'))
The format of the decimal portion of the seconds may be adjusted to
suit taste.
If the original data is a single quantity of one time unit (hours,
minutes, seconds, even days) you just use div, mod, floor(), and
factors like 60 and 3600 as necessary.
.................David Marston
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list