我有两个变量,分别是putdate和puttime(格式为HHMMSSTH)。这两个变量取自mqmd报头。
<xsl:variable name="putdate">
<xsl:value-of select="'20051114'"/>
</xsl:variable>
<xsl:variable name="puttime">
<xsl:value-of select="'10594016'"/>
</xsl:variable>puttime的格式为HHMMSSTH
HH
Hours (00 to 23)
MM
Minutes (00 to 59)
SS
Seconds (00 to 59)
T
Tenths of a second (0 to 9)
H
Hundredths of a second (0 to 9).我有第三个变量,incrementtime,单位是毫秒,在本例中是1990毫秒。我需要xslt做的是将值1990毫秒添加到puttime,我猜下面是步骤
1) Take the 10th value, which is 9(from 1990), then add to puttime's H, which makes it 10594025(9+6=15)
2)Take the 100th value, which is 9(from 1990), then add to puttimes's T, which makes it 10594115(9+2=11)
3)Take the 1000th value, which is 1(from 1990), then add to puttime's SS, which makes it 10594215结果时间是10594315。xslt的输出应该是"2005-11-14 10:59:42:15“(实际上是在GMT中),并转换为Mountain Time。
发布于 2012-02-28 15:41:43
XSLT 1.0没有对时间值的任何内置支持。为了能够添加时间值,你必须自己实现所有的溢出逻辑。
seconds
≥28,29,30⇒≥31⇒Increment minutes
≥28,29,30 or 31⇒Increment months
⇒≥12⇒Increment months
≥≥28,29,30 or 31⇒Increment
≥
然后你还必须处理DST规则,否则当切换日期过去时,值会变得混乱。如果你真的设法实现了它,它最终将成为一大块不可维护的代码。
在XSLT2.0中,xs:dateTime类型(和类似类型)可以为您完成计算。使用XSLT2.0甚至是命令式编程语言(Java、C#、Python等)会简单得多。
https://stackoverflow.com/questions/9476646
复制相似问题