7 users online. Create an account or sign in to join them.Users

Search

A new XSLT utility, “Date utilities” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

Submitted a bug. Ciao :)

Date utilities updated to version 0.1.1 on 5th of December 2010

Ciao @eKoeS

I'd like to use your utility to test if a date in my XML output is earlier than today. The reason I'm not using a data source for this is that my date is stored in a text input so the "earlier than today" filter will not work.

So the XML looks like this:

<member-info>
    <entry>
         <mc-paid-until handle="2011-12-09">2011-12-09</mc-paid-until>
    </entry>
</member-info>

What I'd like to do is to use a choose statement to show a payment form if the $today parameter is later than the value of mc-paid-until or to show a welcome message if $today is the same as or earlier than mc-paid-until.

Is this something the utility can do? If so, please could you suggest what the syntax would be.

Grazie :-)

I've not used this before but looking at the example it should be possible. The date-compare template returns -1, 0 or 1 depending on whether the dates are before, equal or later than one another. You can put this result into a variable then run tests against it:

<xsl:variable name="is-later">
    <xsl:call-template name="date-compare">
        <xsl:with-param name="first" select="mc-paid-until"/>
        <xsl:with-param name="second" select="$today"/>
    </xsl:call-template>
</xsl:variable>

<xsl:choose>
    <xsl:when test="$is-later &gt; 1">
        <!-- date is later -->
    </xsl:when>
    <xsl:otherwise>
        <!-- date is earlier -->
    </xsl:otherwise>
</xsl:choose>

Not sure if I got the order the right way around, but the concept should work.

Ciao Stuart :)

Nick got it right, except for the test condition that should probably be:

$is-later = 1

or

$is-later &gt; 0

Cheers!

Thanks again Nick. Grazie Simone. Tutto va bene :-)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details