From 359124541511997adf5de9bad6f38c1efc9e2c21 Mon Sep 17 00:00:00 2001 From: PeteChu Date: Thu, 15 Oct 2020 19:49:57 +0700 Subject: [PATCH 1/2] Create TimeToSecond.js --- Scripts/TimeToSecond.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Scripts/TimeToSecond.js diff --git a/Scripts/TimeToSecond.js b/Scripts/TimeToSecond.js new file mode 100644 index 00000000..db32cadf --- /dev/null +++ b/Scripts/TimeToSecond.js @@ -0,0 +1,19 @@ +/** + { + "api":1, + "name":"Time to seconds", + "description":"Convert hh:mm:ss to seconds", + "author":"PeteChu", + "icon":"flask", + "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.text = timeToSeconds(input.text) +} From 74b74b4c2d6258afe374e14cc63a18329da5ba1b Mon Sep 17 00:00:00 2001 From: PeteChu Date: Thu, 15 Oct 2020 20:13:44 +0700 Subject: [PATCH 2/2] update icon to watch icon --- Scripts/TimeToSecond.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/TimeToSecond.js b/Scripts/TimeToSecond.js index db32cadf..78a56340 100644 --- a/Scripts/TimeToSecond.js +++ b/Scripts/TimeToSecond.js @@ -4,7 +4,7 @@ "name":"Time to seconds", "description":"Convert hh:mm:ss to seconds", "author":"PeteChu", - "icon":"flask", + "icon":"watch", "tags":"transform,convert" } **/ @@ -15,5 +15,5 @@ function timeToSeconds(durationText) { } function main(input) { - input.text = timeToSeconds(input.text) -} + input.insert('\n\n' + timeToSeconds(input.text)); +} \ No newline at end of file