feat(utils): accept string in time difference

This commit is contained in:
ItzCrazyKns 2024-06-28 09:34:03 +05:30
parent 4545ff1d7d
commit 91bba8eaca
No known key found for this signature in database
GPG Key ID: 8162927C7CCE3065
1 changed files with 7 additions and 1 deletions

View File

@ -3,7 +3,13 @@ import { twMerge } from 'tailwind-merge';
export const cn = (...classes: ClassValue[]) => twMerge(clsx(...classes));
export const formatTimeDifference = (date1: Date, date2: Date): string => {
export const formatTimeDifference = (
date1: Date | string,
date2: Date | string,
): string => {
date1 = new Date(date1);
date2 = new Date(date2);
const diffInSeconds = Math.floor(
Math.abs(date2.getTime() - date1.getTime()) / 1000,
);