FIX: removes time from date in calendar range at midnight (#10751)

This commit is contained in:
Joffrey JAFFEUX
2020-09-28 10:39:21 +02:00
committed by GitHub
parent 4edb769ef2
commit 2b254f4305
2 changed files with 19 additions and 7 deletions

View File

@ -188,12 +188,16 @@ export default class LocalDateBuilder {
); );
if (inCalendarRange && sameTimezone) { if (inCalendarRange && sameTimezone) {
return localDate const date = localDate.datetimeWithZone(this.localTimezone);
.datetimeWithZone(this.localTimezone)
.calendar( if (date.hours() === 0 && date.minutes() === 0) {
moment.tz(localDate.timezone), return date.format("dddd");
this._calendarFormats(this.time ? this.time : null) }
);
return date.calendar(
moment.tz(localDate.timezone),
this._calendarFormats(this.time ? this.time : null)
);
} }
} }

View File

@ -257,10 +257,18 @@ QUnit.test("option[calendar]", (assert) => {
); );
}); });
freezeTime({ date: "2020-03-20 23:59" }, () =>
assert.buildsCorrectDate(
{ date: "2020-03-21", time: "01:00", timezone: PARIS },
{ formated: "Tomorrow 1:00 AM" }
)
);
freezeTime({ date: "2020-03-20 23:59" }, () => freezeTime({ date: "2020-03-20 23:59" }, () =>
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ date: "2020-03-21", time: "00:00", timezone: PARIS }, { date: "2020-03-21", time: "00:00", timezone: PARIS },
{ formated: "Tomorrow 12:00 AM" } { formated: "Saturday" },
"it displays the day with no time when the time in the displayed timezone is 00:00"
) )
); );