-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
The unix timestamps are no very useful for humans, the XSL v.1 has not date(time) functions, but EXSLT has, thus i implemented this template:
<xsl:template name="date-range">
<xsl:param name="utime" select="0"/>
<xsl:choose>
<xsl:when test="function-available('date:add')">
<xsl:variable name="dateTime" select="date:add('1970-01-01T00:00:00', date:duration($utime))"/>
<xsl:variable name="date" select="substring-before($dateTime, 'T')" />
<xsl:variable name="year" select="substring-before($dateTime, '-')" />
<xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />
<xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />
<xsl:variable name="time" select="substring-before(substring-after($dateTime, 'T'), 'Z')" />
<xsl:variable name="hour" select="substring-before($time, ':')" />
<xsl:variable name="mins" select="substring-before(substring-after($time, ':'), ':')" />
<xsl:value-of select="concat($day, '. ', $month, '. ', $year, ' ', $hour, ':', $mins)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$utime"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>It format date/time to our format (DD.MM.YYYY HH:MM) and it is called eg. by this:
<xsl:call-template name="date-range">
<xsl:with-param name="utime" select="feedback/report_metadata/date_range/begin"/>
</xsl:call-template>It requires to define date NS:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times">Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels