XSL and ISO8601 date/time

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 371
Joined: Tue Nov 12, 2013 2:05 am

XSL and ISO8601 date/time

Post by peter_b »

This is a small collection of handling ISO8601 date/time/duration values with XML Stylesheets (XSLT).

Useful links:
User avatar
peter_b
Chatterbox
Posts: 371
Joined: Tue Nov 12, 2013 2:05 am

HowTo: Quick-n-dirty ISO8601 duration from seconds

Post by peter_b »

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:

Code: Select all

<xsl:value-of select="concat('PT', /Video/Duration, 'S')"/>
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.
:D
Post Reply