Fix Today/Yesterday wrong with negative timezones

Applied offset to "now" when comparing with offset timestamps.

Affects issues:
- Possibly fixed #3420
This commit is contained in:
Aurora Lahtela 2024-03-03 10:16:02 +02:00
parent 701866cc6a
commit 12cf9ea414

View File

@ -28,11 +28,11 @@ export function formatDate(date, offset, pattern, recentDays, recentDaysPattern,
let format = pattern; let format = pattern;
if (recentDays) { if (recentDays) {
if (timestamp > now - fromStartOfToday) { if (timestamp > now - offset - fromStartOfToday) {
format = format.replace(recentDaysPattern, t('plugin.generic.today')); format = format.replace(recentDaysPattern, t('plugin.generic.today'));
} else if (timestamp > now - dayMs - fromStartOfToday) { } else if (timestamp > now - offset - dayMs - fromStartOfToday) {
format = format.replace(recentDaysPattern, t('plugin.generic.yesterday')); format = format.replace(recentDaysPattern, t('plugin.generic.yesterday'));
} else if (timestamp > now - dayMs * 5) { } else if (timestamp > now - offset - dayMs * 5) {
format = format.replace(recentDaysPattern, "EEEE"); format = format.replace(recentDaysPattern, "EEEE");
} }
} }