export class DateFormatter { /** * Formats a date as "Jan 18, 2026" using UTC. */ static formatShort(date: string | Date): string { const d = typeof date === 'string' ? new Date(date) : date; const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; return `${months[d.getUTCMonth()]} ${d.getUTCDate()}, ${d.getUTCFullYear()}`; } /** * Formats a date as "Jan 2026" using UTC. */ static formatMonthYear(date: string | Date): string { const d = typeof date === 'string' ? new Date(date) : date; const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; return `${months[d.getUTCMonth()]} ${d.getUTCFullYear()}`; } /** * Formats a date as "15:00" using UTC. */ static formatTime(date: string | Date): string { const d = typeof date === 'string' ? new Date(date) : date; const hours = d.getUTCHours().toString().padStart(2, '0'); const minutes = d.getUTCMinutes().toString().padStart(2, '0'); return `${hours}:${minutes}`; } /** * Formats a date as "Jan 18" using UTC. */ static formatMonthDay(date: string | Date): string { const d = typeof date === 'string' ? new Date(date) : date; const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; return `${months[d.getUTCMonth()]} ${d.getUTCDate()}`; } /** * Formats a date as "Jan 18, 15:00" using UTC. */ static formatDateTime(date: string | Date): string { const d = typeof date === 'string' ? new Date(date) : date; const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; const hours = d.getUTCHours().toString().padStart(2, '0'); const minutes = d.getUTCMinutes().toString().padStart(2, '0'); return `${months[d.getUTCMonth()]} ${d.getUTCDate()}, ${hours}:${minutes}`; } }