From 5477157b4c1956c11a0c89e3f2b1354f829a3590 Mon Sep 17 00:00:00 2001 From: Lera24 Date: Thu, 21 Nov 2024 13:50:43 +0200 Subject: [PATCH] feature: add convertDurationWithMinutes[WTEL-4883](https://webitel.atlassian.net/browse/WTEL-4883) --- package.json | 2 +- src/scripts/convertDurationWithMinutes.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/scripts/convertDurationWithMinutes.js diff --git a/package.json b/package.json index 596eff57..af2f8fcc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@webitel/ui-sdk", - "version": "24.12.1", + "version": "24.12.2", "private": false, "scripts": { "dev": "vite", diff --git a/src/scripts/convertDurationWithMinutes.js b/src/scripts/convertDurationWithMinutes.js new file mode 100644 index 00000000..9c4f726e --- /dev/null +++ b/src/scripts/convertDurationWithMinutes.js @@ -0,0 +1,13 @@ +const convertDurationWithMinutes = (duration) => { + if (!duration) return '00:00'; + + let hour = `${Math.floor(duration / 60)}`; + let min = `${Math.floor(duration % 60)}`; + + if (hour.length === 1) hour = `0${hour}`; + if (min.length === 1) min = `0${min}`; + + return `${hour}:${min}`; +}; + +export default convertDurationWithMinutes;