/** * Date utilities for OpenPrompt * Use these functions to ensure dates are always current */ /** * Get the current year */ export function getCurrentYear(): number { return new Date().getFullYear() } /** * Get the current month and year in format "Month YYYY" */ export function getCurrentMonthYear(): string { const date = new Date() return date.toLocaleDateString('en-US', { month: 'long', year: 'numeric' }) } /** * Get the current date in format "Month DD, YYYY" */ export function getCurrentDate(): string { const date = new Date() return date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) } /** * Get formatted date from Date object */ export function formatDate(date: Date): string { return date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) } /** * Get relative time string (e.g., "2 hours ago", "3 days ago") */ export function getRelativeTime(date: Date): string { const now = new Date() const diffInSeconds = Math.floor((now.getTime() - date.getTime()) / 1000) if (diffInSeconds < 60) return 'just now' if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)} minutes ago` if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)} hours ago` if (diffInSeconds < 604800) return `${Math.floor(diffInSeconds / 86400)} days ago` if (diffInSeconds < 2592000) return `${Math.floor(diffInSeconds / 604800)} weeks ago` if (diffInSeconds < 31536000) return `${Math.floor(diffInSeconds / 2592000)} months ago` return `${Math.floor(diffInSeconds / 31536000)} years ago` }