Skip to content

Instantly share code, notes, and snippets.

@nachoplaza
Created November 12, 2013 14:18
Show Gist options
  • Save nachoplaza/7431549 to your computer and use it in GitHub Desktop.
Save nachoplaza/7431549 to your computer and use it in GitHub Desktop.
Functions for XSLT conversion between dateTime format and Epoch format.
<xsl:call-template name="dateTimeToEpoch">
<xsl:with-param name="dateTimeValue" select="$value"/>
</xsl:call-template>
<xsl:template name="dateTimeToEpoch">
<xsl:param name="dateTimeValue"/>
<xsl:value-of select="( dateTime($dateTimeValue) - xsd:dateTime('1970-01-01T00:00:00') ) div xsd:dayTimeDuration('PT1S')"/>
</xsl:template>
<xsl:template name="epochToDateTime">
<xsl:param name="epochTime"/>
<xsl:value-of select="xsd:dateTime('1970-01-01T00:00:00') + ($epochTime * xsd:dayTimeDuration('PT1S'))"/>
</xsl:template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment