From 99292bd80dbd25a1dad10949e1f601f3bcaf6acf Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Fri, 17 Dec 2021 10:02:45 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=B4=D0=BB=D0=B8=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=B2=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B5=20=D0=A7=D0=A7:?= =?UTF-8?q?=D0=9C=D0=9C:=D0=A1=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/datetime.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/utils/datetime.ts diff --git a/src/utils/datetime.ts b/src/utils/datetime.ts new file mode 100644 index 0000000..2f2bb63 --- /dev/null +++ b/src/utils/datetime.ts @@ -0,0 +1,10 @@ +export const periodToString = (time?: number) => { + if (!time) return '00:00:00' + const hours = Math.floor(time / 3600) + const minutes = Math.floor(time / 60 - hours * 60) + const seconds = Math.floor(time - hours * 3600 - minutes * 60) + + const toFixed = (num: number) => `${num}`.padStart(2, '0') + + return `${toFixed(hours)}:${toFixed(minutes)}:${toFixed(seconds)}` +}