CLiown
CLiown

Reputation: 13843

XSLT - Converting time to minutes

Id like to be able to convert the following XML

<itunes:duration>00:09:54</itunes:duration>

To a total of minutes, I currently just output the complete value but I would like to just display: 0hr 9min 54sec

Or possibly round up to the nearest minute?

Upvotes: 1

Views: 628

Answers (2)

Tommy
Tommy

Reputation: 4111

If you just want to round up you can substring minutes and seconds, and if seconds > 30 -> minutes += 1

Upvotes: 0

brabster
brabster

Reputation: 43560

If you're using an XPath 2.0 supporting processor, there are built in functions you can use. Here's a list, scroll down to the date/time functions.

You probably want something like: minutes-from-time(time)

Watch out for namespace prefixes etc. A prefix isn't required for the functions if your processor dows support XPath 2.0

Upvotes: 1

Related Questions