Skip to content

Instantly share code, notes, and snippets.

@4rass
Last active July 31, 2022 14:51
Show Gist options
  • Save 4rass/726c90f77e0ea14b30b013dae4f69266 to your computer and use it in GitHub Desktop.
Save 4rass/726c90f77e0ea14b30b013dae4f69266 to your computer and use it in GitHub Desktop.
Epoch to date time and date time to epoch
<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