Jump to content

DGrigsbyII

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by DGrigsbyII

  1. On 5/12/2023 at 2:23 AM, Thorsten Vogt said:

    Hello, 

    you could do this by creating a transform and calculating the values inside it. In my example I am using the duration() method to get the duration of the capsule. You might need to change this to get the value from your property.

    $condition.removeLongerThan(1mo).transform($capsule ->
    {
      //Calculate total hours
      $totalHours = $capsule.duration().convertUnits('h').setUnits('')
      
      $hoursFraction = $totalHours - $totalHours.floor()
      $hours = ($totalHours - $hoursFraction).floor()
      
      //Calculate minutes
      $minutes = $hoursFraction * 60
      $minutesFraction = $minutes - $minutes.floor()
      
      //Calculate seconds
      $seconds = ($minutesFraction * 60).round(0)
      
      //Set property by buildung a string
      $capsule.setProperty('Hours', $hours.toString() + ":" + $minutes.floor().toString() + ":" + $seconds.toString())
    })

    image.png.104fe9435cb7218f2095d95e9cc1064c.png

    Regards,

    Thorsten

    This works well and I like the approach except for dealing with minutes and seconds values less than 10. Do you have an approach for that?

  2. I have a condition that has a duration property from child capsules. This property initially returns as a date time string from 1/1/1970 00:00. I want to be able to convert it to purely hh:mm:ss and be able to be larger than 24 hours if needed. What is the best approach to this? 

    I saw some posts on doing a string replace function on the returned property but I couldn't get that to work

     

    This is what I'm using as an example property to test and play with.

    image.png.d60674de1bad66b2f551da70ef6afb64.png

    image.png.b83743061337a93aa8786ecfc4552504.png

     

     

×
×
  • Create New...