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

Search

A new XSLT utility, "Get the next day of a date" 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.

Wouldn't this the be much simpler using EXSLT's date functions? (And leap years would also work!)

This stylesheet can give you a start:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="date">

<xsl:output method="xml"
    omit-xml-declaration="yes"
    encoding="UTF-8"
    indent="yes" />

<xsl:template match="/">
    <xsl:param name="date" select="'2012-02-28'"/>
    <data>
        <date>
            <xsl:value-of select="$date"/>
        </date>
        <one-day-after-date>
            <xsl:value-of select="date:add($date, 'P1D')"/>
        </one-day-after-date>
        <two-days-after-date>
            <xsl:value-of select="date:add($date, 'P2D')"/>
        </two-days-after-date>
    </data>
</xsl:template>

</xsl:stylesheet>

The output will be:

<data>
  <date>2012-02-28</date>
  <one-day-after-date>2012-02-29</one-day-after-date>
  <two-days-after-date>2012-03-01</two-days-after-date>
</data>

[EDIT]: Simplified stylesheet.

I see it as a challenge. Here is the latest version with leap year.

:-)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details