I'm using XSLT to extract timing information from logs in order to
determine the duration of actions. Each log item has a time stamp in the
usual format (2016-10-05T15:52:17.525:+0200).
In order to get the difference between two times I'm manually constructing
dayTimeDurations by constructing a dateTime object and then using the
various accessor functions to get the different components and then
manually making a dayTimeDuration string as input to xs:dayTimeDuration():
<xsl:function name="local:makeDayTimeDuration" as="xs:dayTimeDuration">
<xsl:param name="dateString" as="xs:string"/>
<xsl:variable name="date" as="xs:dateTime"
select="xs:dateTime($dateString)"/>
<xsl:variable name="days" as="xs:integer?"
select="day-from-dateTime($date)"/>
<xsl:variable name="hours" as="xs:integer?"
select="hours-from-dateTime($date)"/>
<xsl:variable name="minutes" as="xs:integer?"
select="minutes-from-dateTime($date)"/>
<xsl:variable name="seconds" as="xs:decimal?"
select="seconds-from-dateTime($date)"/>
<xsl:variable name="dayTimeDurationStr" as="xs:string"
select="concat('P', $days, 'DT', $hours, 'H', $minutes, 'M',
$seconds, 'S')"
/>
<xsl:sequence select="xs:dayTimeDuration($dayTimeDurationStr)"/>
</xsl:function>
This works but I expected to find a function to directly get a
dayTimeDuration from a dateTime, but I didn't find one in the XPath 2.0
operators and functions spec (April 2015 version).
Did I miss something or do I really have to manually construct the
dayTimeDuration string?
Thanks,
Eliot
--
Eliot Kimber
http://contrext.com
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--