import { format, startOfDay, isEqual } from 'date-fns';

export const formatDateHeader = (date: Date) => {
    const today = startOfDay(new Date());
    const itemDate = startOfDay(date);

    if (isEqual(itemDate, today)) {
        return `Today, ${format(itemDate, 'eee, d MMM')}`;
    }
    return format(itemDate, 'eee, d MMM');
};

export const formatDuration = (seconds: number) => {
    const h = Math.floor(seconds / 3600);
    const m = Math.floor((seconds % 3600) / 60);
    const s = Math.round(seconds % 60);
    return [
        h > 0 ? `${h}h` : '',
        m > 0 ? `${m}m` : '',
        s > 0 ? `${s}s` : ''
    ].filter(Boolean).join(' ');
}; 