import { IFormattedDate } from '../types'

const dateFns = new DateFnsUtils();
const toDateFn = (date: Date | string | null) => dateFns.date(date)
const today =  dateFns.date(new Date())
const getDateDelta = (date: string) => dateFns.getDiff(toDateFn(date), today)
const daysDiff = (date: number | Date): number => differenceInDays(date, today)
const hoursDiff = (date: number | Date) => differenceInHours(date, today)

export const timeRemaining = (date: Date | string | null): string => {
    const dateStr = toDateFn(date)
    const totalHours = hoursDiff(dateStr)
    const remainder = totalHours % 24
    const days = Math.floor(totalHours / 24)