Duration formatting

18 views
Skip to first unread message

jamar....@gmail.com

unread,
Oct 13, 2020, 5:56:28 PM10/13/20
to Orbeon Forms
Hi,

I have a simple formula that determines a time duration using 2 time formatted fields and returns a time duration. xs:time($time_off) - xs:time($time_on) eg returns PT1H49M30S. We want to be able to display the duration in a more user friendly output such as 1 hour, 49 mins, 30 sec. Currently I'm was looking at using the substring function to target the time tokens of the duration but I wondered if anyone knew of another way.

Cheers
Jamian

Alessandro Vernet

unread,
Oct 14, 2020, 2:12:06 AM10/14/20
to orb...@googlegroups.com
Hi Jamian,

You can use the component extraction functions on durations (see 1st link
below), for instance the following would return 49.

minutes-from-duration(xs:dayTimeDuration('PT1H49M30S'))

https://www.w3.org/TR/xpath-functions-30/#component-extraction-durations

I hope this helps,

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

jamar....@gmail.com

unread,
Oct 15, 2020, 1:13:02 AM10/15/20
to Orbeon Forms
Thank you Alex! 
Works beautifully!

Cheers
Jamian

Alessandro Vernet

unread,
Oct 15, 2020, 1:50:39 PM10/15/20
to orb...@googlegroups.com
Perfect Jamian, and thank you for the confirmation.
Reply all
Reply to author
Forward
0 new messages