FIX: end date of ranges in html preview was incorrect (#9654)

This commit also remove an unused block of code as previewedTimezones can't be empty anymore.
This commit is contained in:
Joffrey JAFFEUX 2020-05-06 17:16:36 +02:00 committed by GitHub
parent c99ecba68f
commit 2f714c7412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 15 deletions

View File

@ -113,22 +113,16 @@ export default class LocalDateBuilder {
previewedTimezones.push({ previewedTimezones.push({
timezone: this._zoneWithoutPrefix(timezone), timezone: this._zoneWithoutPrefix(timezone),
formated: this._createDateTimeRange( formated: this._createDateTimeRange(
localDate.datetimeWithZone(timezone), DateWithZoneHelper.fromDatetime(
localDate.datetime,
localDate.timezone,
timezone
),
this.time this.time
) )
}); });
}); });
if (!previewedTimezones.length) {
previewedTimezones.push({
timezone: "UTC",
formated: this._createDateTimeRange(
localDate.datetimeWithZone("Etc/UTC"),
this.time
)
});
}
return previewedTimezones.uniqBy("timezone"); return previewedTimezones.uniqBy("timezone");
} }

View File

@ -330,7 +330,7 @@ QUnit.test("previews", assert => {
}, },
{ {
formated: formated:
"Monday, March 23, 2020 10:00 AM → Monday, March 23, 2020 10:00 AM", "Sunday, March 22, 2020 10:00 AM → Monday, March 23, 2020 10:00 AM",
timezone: "Sydney" timezone: "Sydney"
} }
] ]
@ -403,7 +403,11 @@ QUnit.test("previews", assert => {
freezeTime({ date: "2020-04-06", timezone: PARIS }, () => { freezeTime({ date: "2020-04-06", timezone: PARIS }, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(
{ timezone: PARIS, date: "2020-04-07", timezones: [LONDON, LAGOS] }, {
timezone: PARIS,
date: "2020-04-07",
timezones: [LONDON, LAGOS, SYDNEY]
},
{ {
previews: [ previews: [
{ {
@ -414,13 +418,50 @@ QUnit.test("previews", assert => {
}, },
{ {
formated: formated:
"Tuesday, April 7, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM", "Monday, April 6, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM",
timezone: "London" timezone: "London"
}, },
{ {
formated: formated:
"Tuesday, April 7, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM", "Monday, April 6, 2020 11:00 PM → Tuesday, April 7, 2020 11:00 PM",
timezone: "Lagos" timezone: "Lagos"
},
{
formated:
"Tuesday, April 7, 2020 8:00 AM → Wednesday, April 8, 2020 8:00 AM",
timezone: "Sydney"
}
]
}
);
});
freezeTime({ date: "2020-04-06", timezone: PARIS }, () => {
assert.buildsCorrectDate(
{
timezone: PARIS,
date: "2020-04-07",
time: "14:54",
timezones: [LONDON, LAGOS, SYDNEY]
},
{
previews: [
{
current: true,
formated: "April 7, 2020 2:54 PM",
timezone: "Paris"
},
{
formated: "April 7, 2020 1:54 PM",
timezone: "London"
},
{
formated: "April 7, 2020 1:54 PM",
timezone: "Lagos"
},
{
formated: "April 7, 2020 10:54 PM",
timezone: "Sydney"
} }
] ]
} }