RE: date difference problem

Bhushan Bhangale <[email protected]>
Newsgroups gmane.text.xml.xslt.extensions
Message-ID <A9F75F9AB514D611A69D0002A5AD9BED12BE6847@lmnukex05.lastminute.com>
Ohh
Thanks Jeni.

How can I do such a silly mistake :-((

-----Original Message-----
From: Jeni Tennison [mailto:[email protected]]
Sent: 04 November 2003 14:39
To: Bhushan Bhangale
Cc: [email protected]
Subject: Re: [exslt] date difference problem


Hi Bhushan,

> I used the date difference template to get the difference between 2
> dates. I read the whole doc but the template output is not what it
> should be. Below is the call template syntax I used.
>
> <xsl:call-template name="date:difference">   
>     <xsl:with-param name="start" select="2003-12-31" />   
>     <xsl:with-param name="end" select="2003-12-04" />
> </xsl:call-template>
>
> The output should be -P0Y0M27D
>
> But the output is P27Y

You've missed out the quotes around the dates. The values of the
select attributes are being evaluated. 2003 - 12 - 31 is 1960, and
2003 - 12 - 4 is 1987. These are interpreted as xs:gYear values, and
there's a gap of 27 years between 1960 and 1987.

If you add quotes, so that the call is:

<xsl:call-template name="date:difference">
  <xsl:with-param name="start" select="'2003-12-31'" />
  <xsl:with-param name="end" select="'2003-12-04'" />
</xsl:call-template>

then the template will give you the difference between the dates
2003-12-31 and 2003-12-04, and return -P27D, as you expect.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.