Duration formatting

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Duration formatting

Jamian Manton
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

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/d7fdb78a-c3f2-437e-b9a5-5aad9195058an%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Duration formatting

Alessandro  Vernet
Administrator
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/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1602655922713-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Duration formatting

Jamian Manton
Thank you Alex! 
Works beautifully!

Cheers
Jamian

On Wednesday, October 14, 2020 at 5:12:06 PM UTC+11 Alessandro Vernet wrote:
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/

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/8d3611dd-df84-47e1-8d76-f59e15109dbcn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Duration formatting

Alessandro  Vernet
Administrator
Perfect Jamian, and thank you for the confirmation.

‑Alex

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

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1602784234573-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet