This is a small collection of handling ISO8601 date/time/duration values with XML Stylesheets (XSLT).
Useful links:
XSL and ISO8601 date/time
HowTo: Quick-n-dirty ISO8601 duration from seconds
This HowTo explains how to easily reformat a duration value in seconds (or nanoseconds, microseconds, etc) into an ISO8601 duration.
Assume, we have duration source value of 297,44 seconds.
Let's say we have it under the name "/Video/Duration".
Now, we just need to add the letter "P" (to indicate a duration), and "T" to indicate that it's time - and then "S" at the end, for seconds:
It might not look as beautiful as formatted as hours, minutes, seconds - but it's actually easier to read back, parse and convert it to whatever output format you need.
Assume, we have duration source value of 297,44 seconds.
Let's say we have it under the name "/Video/Duration".
Now, we just need to add the letter "P" (to indicate a duration), and "T" to indicate that it's time - and then "S" at the end, for seconds:
Code: Select all
<xsl:value-of select="concat('PT', /Video/Duration, 'S')"/>