Files
api/helpers/time/dateDiff.ts
2023-08-07 17:51:27 -07:00

12 lines
408 B
TypeScript

import dayjs from 'dayjs';
import preciseDateDiff from './preciseDateDiff';
const readbleDifference = (a = '', b = '') => {
const x = a ? dayjs(parseInt(a, 10)) : dayjs();
const y = b ? dayjs(parseInt(b, 10)) : dayjs();
return preciseDateDiff(x, y);
};
const dateDiff = (time: string, countUp: boolean) => countUp ? readbleDifference(time, '') : readbleDifference('', time);
export default dateDiff;