SoWhat
SoWhat

Reputation: 5622

Convert Jira's time tracking field format to hours

I am using JIRA api to extract timespent by users on issues. The time spent is in the format:

"12w 1d 2h 5m" or "12h" or "12m" etc

The API isn't exporting the number of hours. Is there a quick (requires no effort on my part) way to convert this to hours (or seconds). I suppose this is some sort of a standard format, is there a name for it? I know how to do this myself, just don't want to reinvent the wheel

Upvotes: 1

Views: 1213

Answers (2)

Oles Hnatkevych
Oles Hnatkevych

Reputation: 93

Take a look at JiraDurationUtils. It will use the Time Tracking configuration to convert properly.

Upvotes: 0

Abe Voelker
Abe Voelker

Reputation: 31564

The chronic_duration gem can parse that into seconds:

ChronicDuration.parse("12w 1d 2h 5m") # => 7351500

As far as I know that format isn't a standard. ISO 8601 does include a format for durations, but that ain't it.

Upvotes: 2

Related Questions