mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* first part of migration * second part of migration * bump up es-toolkit version * bump up `es-toolkit` version and remove `lodash` completely * update screenshot
16 lines
539 B
TypeScript
16 lines
539 B
TypeScript
import { padStart } from 'es-toolkit/compat';
|
|
|
|
export default function splitSecondsInPeriods(value: number) {
|
|
const seconds = value % 60;
|
|
const minutes = (value - seconds) / 60 % 60;
|
|
const hours = (value - seconds - minutes * 60) / (60 * 60) % 24;
|
|
const days = (value - seconds - minutes * 60 - hours * 60 * 60) / (60 * 60 * 24);
|
|
|
|
return {
|
|
seconds: padStart(String(seconds), 2, '0'),
|
|
minutes: padStart(String(minutes), 2, '0'),
|
|
hours: padStart(String(hours), 2, '0'),
|
|
days: padStart(String(days), 2, '0'),
|
|
};
|
|
}
|