【发布时间】:2020-10-21 17:34:30
【问题描述】:
我们有 GMT 的日期时间,并希望将其转换为 EST。当我们尝试低于 xsl 时,我们得到一个错误。
FORG0001:无效的 dateTime 值“05/26/20 14:58”(非数字年份部分)
这是我的 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>
预期输出- 我们希望将此日期时间转换为相应的 EST 日期时间。
注意- 我们使用的是 xslt 2.0 处理器。
【问题讨论】:
-
XPath/XSLT 2 及更高版本的
xs:date格式为例如2020-06-26,xs:dateTime格式,例如2020-06-26T14:58:00所以你需要分解你得到的字符串输入以提取相关组件并重新排序/重新格式化它们以构造xs:dateTime的正确输入格式。substring函数或replace函数或tokenize或analyze-string调用所有帮助。