/**
 * DashboardDateDisplay
 * 
 * Deterministic date formatting for dashboard display.
 * No Intl.* or toLocale* methods.
 */

export interface DashboardDateDisplayData {
  date: string;
  time: string;
  relative: string;
}

/**
 * Format date for display (deterministic, no Intl)
 */
export class DashboardDateDisplay {
  static format(date: Date): DashboardDateDisplayData {
    const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
    const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
    
    const dayName = days[date.getDay()];
    const month = months[date.getMonth()];
    const day = date.getDate();
    const year = date.getFullYear();
    
    const hours = date.getHours().toString().padStart(2, '0');
    const minutes = date.getMinutes().toString().padStart(2, '0');
    
    // Calculate relative time (deterministic)
    const now = new Date();
    const diffMs = date.getTime() - now.getTime();
    const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
    const diffDays = Math.floor(diffHours / 24);
    
    let relative: string;
    if (diffHours < 0) {
      relative = 'Past';
    } else if (diffHours === 0) {
      relative = 'Now';
    } else if (diffHours < 24) {
      relative = `${diffHours}h`;
    } else {
      relative = `${diffDays}d`;
    }
    
    return {
      date: `${dayName}, ${month} ${day}, ${year}`,
      time: `${hours}:${minutes}`,
      relative,
    };
  }
}