✨ feat(formatting): Update differenceInDays function to return whole days or two decimal places
This commit is contained in:
parent
85f55def2e
commit
bf58f25072
@ -28,6 +28,6 @@ export function formatDate(date?: Date | number, showTime: boolean = true) {
|
||||
export function differenceInDays(dateLeft: Date | number, dateRight: Date | number) {
|
||||
const diffInMs = differenceInMilliseconds(dateLeft, dateRight);
|
||||
const diffInDays = diffInMs / (1000 * 60 * 60 * 24);
|
||||
if (diffInDays % 1 === 0) return diffInDays;
|
||||
return Number(diffInDays.toFixed(1));
|
||||
if (diffInDays >= 1) return diffInDays.toFixed(0);
|
||||
return Number(diffInDays.toFixed(2));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user