From bf38645d74cda366ece2d49e9de0b71d80082d87 Mon Sep 17 00:00:00 2001 From: andupetcu <47487320+andupetcu@users.noreply.github.com> Date: Mon, 22 Sep 2025 09:25:58 +0300 Subject: [PATCH] Fix relativeTime API usage correctly - Changed from incorrect f.relativeTime(number, unit, options) to correct f.relativeTime(date, now) - The function expects two Date objects, not a number and unit string - This properly eliminates the ENVIRONMENT_FALLBACK warning - Simplified the implementation to use next-intl's built-in formatting --- app/[locale]/prayers/page.tsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/[locale]/prayers/page.tsx b/app/[locale]/prayers/page.tsx index cf508bd..ffdb2aa 100644 --- a/app/[locale]/prayers/page.tsx +++ b/app/[locale]/prayers/page.tsx @@ -250,19 +250,17 @@ export default function PrayersPage() { const formatTimestamp = (timestamp: Date) => { const currentTime = new Date() - const diff = currentTime.getTime() - timestamp.getTime() - const minutes = Math.floor(diff / (1000 * 60)) - const hours = Math.floor(minutes / 60) - const days = Math.floor(hours / 24) try { - // Provide the 'now' parameter to avoid the warning - if (days > 0) return f.relativeTime(-days, 'day', { now: currentTime }) - if (hours > 0) return f.relativeTime(-hours, 'hour', { now: currentTime }) - if (minutes > 0) return f.relativeTime(-minutes, 'minute', { now: currentTime }) - return f.relativeTime(0, 'second', { now: currentTime }) + // Use the correct API: relativeTime(date, now) + return f.relativeTime(timestamp, currentTime) } catch (e) { // Fallback to simple formatting if relativeTime fails + const diff = currentTime.getTime() - timestamp.getTime() + const minutes = Math.floor(diff / (1000 * 60)) + const hours = Math.floor(minutes / 60) + const days = Math.floor(hours / 24) + if (days > 0) return locale === 'ro' ? `acum ${days} ${days === 1 ? 'zi' : 'zile'}` : `${days} ${days === 1 ? 'day' : 'days'} ago` if (hours > 0) return locale === 'ro' ? `acum ${hours} ${hours === 1 ? 'oră' : 'ore'}` : `${hours} ${hours === 1 ? 'hour' : 'hours'} ago` if (minutes > 0) return locale === 'ro' ? `acum ${minutes} ${minutes === 1 ? 'minut' : 'minute'}` : `${minutes} ${minutes === 1 ? 'minute' : 'minutes'} ago`