From 939312ee1b7f51f8e287427133c91c0093996cd2 Mon Sep 17 00:00:00 2001 From: Wiwi Kuan Date: Thu, 18 Feb 2021 20:23:15 +0800 Subject: [PATCH] Update main.js leftPad padStart length is wrong --- main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 8b7c0bf..14156fd 100644 --- a/main.js +++ b/main.js @@ -123,14 +123,15 @@ function makeSRT() { let eh, em, es, ems; const [timeStart, timeEnd] = lines[i]; const leftPad = str => `${str}`.padStart(2, '0'); + const leftPad3 = str => `${str}`.padStart(3, '0'); sh = leftPad(Math.floor(timeStart / 3600)); sm = leftPad(Math.floor((timeStart % 3600) / 60)); ss = leftPad(Math.floor(timeStart % 60)); - sms = leftPad(Math.floor((timeStart * 1000) % 1000)); + sms = leftPad3(Math.floor((timeStart * 1000) % 1000)); eh = leftPad(Math.floor(timeEnd / 3600)); em = leftPad(Math.floor((timeEnd % 3600) / 60)); es = leftPad(Math.floor(timeEnd % 60)); - ems = leftPad(Math.floor((timeEnd * 1000) % 1000)); + ems = leftPad3(Math.floor((timeEnd * 1000) % 1000)); srt += `${sh}:${sm}:${ss},${sms} --> ${eh}:${em}:${es},${ems}\n`; srt += subTexts[i];