Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Date and Time (5/7) >

Subtracting times

XSLT

      <xsl:stylesheet
                  xmlns:sch="http://www.w3.org/2001/XMLSchema"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0"
                  exclude-result-prefixes=" sch">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <a>
                        <xsl:value-of  select="'12:12:12' cast as sch:time - '05:22:12' cast as sch:time"/>
                  </a>
                  <b>
                        <xsl:value-of  select="'00:00:00' cast as sch:time - '11:11:11' cast as sch:time"/>
                  </b>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

      <a>PT6H50M</a>
      <b>-PT11H11M11S</b>


Previous chapter: Recursions
Next chapter: Comments and processing instructions
Previous page: Extracting all data from dateTime
Next page: Subtracting dates