Skip to content

Commit

Permalink
Merge pull request #201 from PeteChu/main
Browse files Browse the repository at this point in the history
Time to seconds script
  • Loading branch information
IvanMathy authored Mar 16, 2021
2 parents 603d5b0 + 74b74b4 commit 8201524
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Scripts/TimeToSecond.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
{
"api":1,
"name":"Time to seconds",
"description":"Convert hh:mm:ss to seconds",
"author":"PeteChu",
"icon":"watch",
"tags":"transform,convert"
}
**/

function timeToSeconds(durationText) {
const [hours = 0, minutes = 0, seconds = 0] = String(durationText).split(':');
return Number(hours) * 3600 + Number(minutes) * 60 + Number(seconds);
}

function main(input) {
input.insert('\n\n' + timeToSeconds(input.text));
}

0 comments on commit 8201524

Please sign in to comment.