Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How do I convert seconds to pretty print format?

Given the value of e.g. aggregatetimeoriginalestimate, how do I convert this value in seconds to a pretty print format like "2d 4h"?

2 answers

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 02, 2022

Hi @Peder Alm 

Have you tried using the diff() with prettyPrint and use a date/time value as an intermediary?

For example, diff on now and now + your field value. Maybe something like this:

{{now.diff(now.plusSeconds(issue.aggregatetimeoriginalestimate)).prettyPrint}}

 

Kind regards,
Bill

This is pretty close! But sometimes I get something like "2 hours 59 minutes 59 seconds" when I have "3h" as input. Maybe because now is called twice? What if now is just called once to a variable? Is it even possible to work with variables in this small field?

 

Also if I have "2d" as input I get "16h" as output. Can this be changed sp the output is "2d"?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 14, 2022

Maybe that is it...or it is a rounding thing caused by diff() and number representation.

Created variables sometimes work with functions...and sometimes not.  You can try it to learn if they are supported for this case.

For example:

  • create a variable named varNow set to {{now}}
  • use the variable in the expression as:
    • {{varNow.asDate.diff(varNow.asDate.plusSeconds(issue.aggregatetimeoriginalestimate)).prettyPrint}}

For the second part on 2d and 16h, I suspect that is also a rounding thing.  I would submit a support ticket to ask Atlassian for that one.

0 votes
Dan Tombs
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 02, 2022

Hi @Peder Alm

Are you trying to convert the value of the aggregate into another field?

Dan

Yes, exactly! I simplified my question, but the origin of my question is mentioned in ∑original estimate ∑Time spent usage . I have calculated a time estimate value and have the result in seconds, but would like to present it in a read-only field. The value in seconds is displayed correctly in the field, but when I try to convert it and change the output using different methods, I don't get what I want, a human readable format, e.g. "2d 4h", instead of displaying seconds or hours.

Dan Tombs
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Nov 02, 2022

Ahhhh okay. Perfect, thanks for the other details, I now get what you are trying to properly achieve. The short answer is no. As of right now there is no way the automation engine can understand that 60 minutes means one hour and therefore display as 1h.

 

I tend to find that reporting in minutes is the easiest for my users followed by hours.

I had an idea that I could use the prettyPrint unit from diff() in some way. So I wanted to convert my time estimate value in seconds to a DateTime object (donät know how!) and then diff it to 0, e.g. "myTimeEstimateValueAsDateTimeObject.diff(0).prettyPrint". COuld that be a possible solution?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events