Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get values from input
- const { recordDuration, description } = input
- // duration seconds => hours, mins, seconds
- function secondsToHMS(d) {
- d = Number(d);
- var h = Math.floor(d / 3600);
- var m = Math.floor(d % 3600 / 60);
- var s = Math.floor(d % 3600 % 60);
- var hDisplay = h > 0 ? h + (h == 1 ? " hour " : " hours ") : "";
- var mDisplay = m > 0 ? m + (m == 1 ? " minute " : " minutes ") : "";
- var sDisplay = s > 0 ? s + (s == 1 ? " second" : " seconds") : "";
- return hDisplay + mDisplay + sDisplay;
- }
- const duration = secondsToHMS(recordDuration)
- if (description && description.includes(".atlassian.net/browse/")) {
- // parse Jira key from description
- const descriptionSplit = description.split(".atlassian.net/browse/")
- const jiraKey = descriptionSplit.length > 1 ? descriptionSplit[1].split()[0] : ""
- const key = jiraKey.split(/(\s)/)
- output = [{duration, jiraKey: key[0]}];
- } else {
- output = [{duration, jiraKey: null}];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement