You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Zhu Di <fl...@gmail.com> on 2006/10/25 13:41:03 UTC

How to add 0.001 second to a dateTime format value

hi,

I need some help on how to calculate dateTime format value

for example

<date>2006-06-06T12:00:12.123</date>

now I want to increast that value by 0.001 second.

I had try something like this


<xsl:value-of select="(preceding::date + 'PT0.001S')"/>

but it returns NaN. so what should I do?

RE: {Spam?} How to add 0.001 second to a dateTime format value

Posted by Warrell <wa...@iquo.co.uk>.
Hi Zhu,

 

It is not as simple as you have anticipated ;-)

 

The contents of the <date> element is just a string. I assume from your code
snippet that you have some XSLT in which you want to manipulate the date for
use by the next stage of the Cocoon pipeline.

 

You would first need to convert the string into a java or javascript date
then add your 0.001 second to it. You would then convert the result into the
contents of an XML element.

 

However, If this number is coming from a database query or any other
generator or transform you might want to consider doing the arithmetic
there.

 

 

  _____  

From: Zhu Di [mailto:flutina@gmail.com] 
Sent: 25 October 2006 12:41
To: users@cocoon.apache.org
Subject: {Spam?} How to add 0.001 second to a dateTime format value

 

hi,

 

I need some help on how to calculate dateTime format value

 

for example

 

<date>2006-06-06T12:00:12.123</date>

 

now I want to increast that value by 0.001 second.

 

I had try something like this 

 

< 

xsl:value-of select="(preceding::date + 'PT0.001S')"/> 

but it returns NaN. so what should I do?