Reputation: 388
We have date-time in GMT and want to convert it in EST. when we are trying below xsl, we are getting an error.
FORG0001: Invalid dateTime value "05/26/20 14:58" (Non-numeric year component)
Here is my xsl-
<xsl:variable name="estDateTime">
<xsl:call-template name="convertGMTToEST">
<xsl:with-param name="gmtDateTime" select="'05/26/20 14:58'"/>
</xsl:call-template>
</xsl:variable>
<xsl:template name="convertGMTToEST">
<xsl:param name="gmtDateTime" />
<xsl:value-of select="adjust-dateTime-to-timezone(xs:dateTime($gmtDateTime),xs:dayTimeDuration('-PT5H'))"/>
</xsl:template>
Expected Output- we want this date time to be converted into the corresponding EST date-time.
Note- we are using xslt 2.0 processor.
Upvotes: 1
Views: 1658
Reputation: 163625
Consider using the saxon:parse-dateTime()
extension function:
https://www.saxonica.com/documentation/index.html#!functions/saxon/parse-dateTime
Requires Saxon-PE or higher, Saxon 10 onwards.
Upvotes: 0
Reputation: 167716
xs:dateTime(replace('05/26/20 14:58', '([0-9]{2})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})', '20$3-$1-$2T$4:$5:00'))
might work for the particular sample but of course if there is any variation in the input format with four digit years or seconds in the time part you will probably need more than a single, simple replace call.
Upvotes: 0