This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: format-number and time or ???



Earlier I wrote:
concat(format-number($hours,'#0'),':',
       format-number($minutes,'00'),':',
       format-number($seconds,'00.###'))

If you start with $data containing the amount of time in seconds,
$seconds is ($data mod 60)
$minutes is ((floor($data div 60)) mod 60)
$hours  is  (floor($data div 3600))

If you start with $data containing the amount of time in minutes,
$seconds is (($data * 60) mod 60)
$minutes is (floor($data) mod 60)
$hours  is  (floor($data div 60))

If you start with $data containing the amount of time in hours,
$seconds is (($data * 3600) mod 60)
$minutes is (floor($data * 60) mod 60)
$hours  is  (floor($data))

The above formulae allow decimal fractions of a second to fall
through, which you'll trim in the formatting anyway. They also
allow $hours to be arbitrarily large, so you may want to expand
the format string (###0) or add another calculation for days.
.................David Marston


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]