【发布时间】:2020-10-22 18:27:16
【问题描述】:
我们正在尝试将日期时间从 GMT 转换为 EST,以便我们遵循这种方法。
- 我们在字符串中获取没有时区的日期时间,然后将时区附加到它。
- 附加时区后,将 DateTime 从 GMT 转换为 EST。
- adjust-dateTime-to-timezone 将返回 EST 中的日期时间 时区。
- 现在,我们希望从该模板中以字符串形式返回不带时区的 EST 日期时间。
这是我的 xsl -
<xsl:template name="convertGMTToEST">
<xsl:param name="gmtDateTime" />
<xsl:variable name="gmtDateTimeWithTimeZone" select="concat($gmtDateTime,'+00:00')"/>
<xsl:variable name="estDateTime" select="adjust-dateTime-to-
timezone(xs:dateTime($gmtDateTimeWithTimeZone),xs:dayTimeDuration('-PT5H'))"/>
<xsl:value-of select="substring-before($estDateTime, '-')"/>
</xsl:template>
预期输出-
我们想在 xs:String 中返回没有时区的 EST dateTime。
我们如何在执行 substring-before 之前将 xs:dateTime 转换为 xs:string 作为 fn:substring-before() 的第一个参数是 xs: string;
注意- 我们使用的是 xslt 2.0 处理器.
【问题讨论】:
-
检查您最喜欢的 XPath 函数参考中的
format-dateTime函数,例如 w3.org/TR/xpath-functions/#date-time-examples。
标签: xml datetime xslt xpath saxon