Skip to content

Commit

Permalink
fix: addings seconds utility /3
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Hoogendoorn committed Sep 15, 2024
1 parent bad8a32 commit 5640da7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/easy/src/utils/Seconds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { ifTrue } from './If';
import { toList } from '../types/List';

export const seconds = {
toDuration: (s: number = 0) => {
toDuration: (s: number) => {
const seconds = s % 60;
const minutes = Math.floor(s / 60) % 60;
const hours = Math.floor(s / 3600) % 24;
const days = Math.floor(s / 86400);
return { days, hours, minutes, seconds };
},

toText: (s: number = 0) => {
toText: (s: number) => {
const { days, hours, minutes, seconds: secs } = seconds.toDuration(s);
return toList(ifTrue(days, `${days}d`), ifTrue(hours, `${hours}h`), ifTrue(minutes, `${minutes}m`), ifTrue(days + hours + minutes === 0, `${secs}s`))
.mapDefined(s => s)
Expand Down

0 comments on commit 5640da7

Please sign in to comment.