xsl-list
[Top] [All Lists]

RE: Date Difference

2005-12-20 17:59:49
If you've got tokenize() and subsequence() available then you've also got
XPath 2.0 date arithmetic available. Just write one function to convert your
local date format into ISO dates, and then use the standard XPath 2.0 date
library.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: thomas(_dot_)maciejewski(_at_)sgcib(_dot_)com 
[mailto:thomas(_dot_)maciejewski(_at_)sgcib(_dot_)com] 
Sent: 19 December 2005 21:57
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Date Difference

I wrote this:

      <xsl:function name="sgfr:IsDateGreater">
            <xsl:param name="stringDate1"/>
            <xsl:param name="stringDate2"/>
            <xsl:variable name="tokenizedDate1"
select="tokenize($stringDate1, '/')"/>
            <xsl:variable name="monthPart1"
select="subsequence(($tokenizedDate1), 1, 1)"/>
            <xsl:variable name="datePart1"
select="subsequence(($tokenizedDate1), 2, 1)"/>
            <xsl:variable name="yearPart1"
select="subsequence(($tokenizedDate1), 3, 1)"/>
            <xsl:variable name="tokenizedDate2"
select="tokenize($stringDate2, '/')"/>
            <xsl:variable name="monthPart2"
select="subsequence(($tokenizedDate2), 1, 1)"/>
            <xsl:variable name="datePart2"
select="subsequence(($tokenizedDate2), 2, 1)"/>
            <xsl:variable name="yearPart2"
select="subsequence(($tokenizedDate2), 3, 1)"/>
            <xsl:choose>
                  <xsl:when test="yearPart1>yearPart2"><xsl:value-of
select="true"/></xsl:when>
                  <xsl:when test="yearPart1=yearPart2">
                        <xsl:choose>
                              <xsl:when test="monthPart1>monthPart2">
                                    <xsl:value-of select="true"/>
                              </xsl:when>
                              <xsl:when test="monthPart1=monthPart2">
                                    <xsl:choose>
                                          <xsl:when
test="datePart1>datePart2"><xsl:value-of select="true"/></xsl:when>
                                          <xsl:otherwise><xsl:value-of
select="false"/></xsl:otherwise>
                                    </xsl:choose>
                              </xsl:when>
                              <xsl:otherwise><xsl:value-of
select="false"/></xsl:otherwise>
                        </xsl:choose>
                  </xsl:when>
                  <xsl:otherwise><xsl:value-of
select="false"/></xsl:otherwise>
            </xsl:choose>
      </xsl:function>

Will this work?
Or am I totally missing the point?

Regards,


Tom Maciejewski


**************************************************************
***********
This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited. 
E-mails are susceptible to alteration.   
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates 
shall be liable for the message if altered, changed or falsified. 

**************************************************************
***********

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>