FIX: ensures seconds are displayed when used with dates (#10170)

This commit is contained in:
Joffrey JAFFEUX 2020-07-06 09:26:31 +02:00 committed by GitHub
parent 6d17765924
commit b2a2e4f1e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View File

@ -24,7 +24,7 @@ export default class LocalDateBuilder {
build() { build() {
const [year, month, day] = this.date.split("-").map(x => parseInt(x, 10)); const [year, month, day] = this.date.split("-").map(x => parseInt(x, 10));
const [hour, minute] = (this.time || "") const [hour, minute, second] = (this.time || "")
.split(":") .split(":")
.map(x => (x ? parseInt(x, 10) : undefined)); .map(x => (x ? parseInt(x, 10) : undefined));
@ -42,6 +42,7 @@ export default class LocalDateBuilder {
day, day,
hour, hour,
minute, minute,
second,
timezone: this.timezone, timezone: this.timezone,
localTimezone: this.localTimezone localTimezone: this.localTimezone
}); });

View File

@ -1,3 +1,4 @@
import I18n from "I18n";
import LocalDateBuilder from "./local-date-builder"; import LocalDateBuilder from "./local-date-builder";
const UTC = "Etc/UTC"; const UTC = "Etc/UTC";
@ -68,15 +69,23 @@ QUnit.test("date", assert => {
{ formated: "March 22, 2020" }, { formated: "March 22, 2020" },
"it displays the date without time" "it displays the date without time"
); );
assert.buildsCorrectDate(
{ date: "2020-04-11", time: "11:00" },
{ formated: "April 11, 2020 1:00 PM" },
"it displays the date with time"
);
}); });
}); });
QUnit.test("date and time", assert => {
assert.buildsCorrectDate(
{ date: "2020-04-11", time: "11:00" },
{ formated: "April 11, 2020 1:00 PM" },
"it displays the date with time"
);
assert.buildsCorrectDate(
{ date: "2020-04-11", time: "11:05:12", format: "LTS" },
{ formated: "1:05:12 PM" },
"it displays full time (hours, minutes, seconds)"
);
});
QUnit.test("option[format]", assert => { QUnit.test("option[format]", assert => {
freezeTime({ date: "2020-03-11" }, () => { freezeTime({ date: "2020-03-11" }, () => {
assert.buildsCorrectDate( assert.buildsCorrectDate(