This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Q on ISO TimeDate convertion


Hi Walter,

> I have an XSLT Template that converts the ISO TimeDate format to an
> American Standard display.
>
>     2001-10-18T12:27:46
>
>     10/18/2001 12:27:46

You could use the date/time extension functions from EXSLT to do this.
See:

  http://www.exslt.org/date/functions/format-date
  
If you don't want to use an extension function, there's an equivalent
date:format-date template that you could call with:

  <xsl:call-template name="date:format-date">
    <xsl:with-param name="date-time" select="'2001-10-18T00:27:46'" />
    <xsl:with-param name="format" select="'MM/dd/yyyy hh:mm:ss a'" />
  </xsl:call-template>

to get the formatting that you want. Or if you don't want to go the
whole hog, then looking at the code might help. The relevant part for
getting the 12-hour clock is:

  <xsl:variable name="h" select="$hour mod 12" />
  <xsl:choose>
    <xsl:when test="$h">
      <xsl:value-of select="format-number($h, $padding)" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="format-number(12, $padding)" />
    </xsl:otherwise>
  </xsl:choose>

Cheers,

Jeni

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


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]