Date: Avoid weekday confusion (#5587)
This commit is contained in:
parent
951378f7c9
commit
8922beda37
@ -223,11 +223,12 @@ export function formatHumanDate(
|
||||
return (isUpperFirst || !isShort ? upperFirst : lowerFirst)(lang('Weekday.Yesterday'));
|
||||
}
|
||||
|
||||
const weekAgo = new Date(today);
|
||||
const weekAhead = new Date(today);
|
||||
weekAgo.setDate(today.getDate() - 7);
|
||||
weekAhead.setDate(today.getDate() + 7);
|
||||
if (date >= weekAgo && date <= weekAhead) {
|
||||
const limitBefore = new Date(today);
|
||||
limitBefore.setDate(today.getDate() - 6); // Avoid returning same weekday as today
|
||||
const limitAhead = new Date(today);
|
||||
limitAhead.setDate(today.getDate() + 6);
|
||||
|
||||
if (date >= limitBefore && date <= limitAhead) {
|
||||
const weekDayString = formatWeekday(lang, date.getDay(), isShort);
|
||||
return (isUpperFirst || !isShort ? upperFirst : lowerFirst)(weekDayString);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user