Add weekday to formatTimeWeekday() (#11020)
This commit is contained in:
parent
e57477c16a
commit
1010777139
|
@ -43,9 +43,9 @@ export const formatTimeWeekday = (dateObj: Date, locale: FrontendLocaleData) =>
|
|||
const formatTimeWeekdayMem = memoizeOne(
|
||||
(locale: FrontendLocaleData) =>
|
||||
new Intl.DateTimeFormat(locale.language, {
|
||||
weekday: "long",
|
||||
hour: useAmPm(locale) ? "numeric" : "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
hour12: useAmPm(locale),
|
||||
})
|
||||
);
|
||||
|
|
|
@ -3,6 +3,7 @@ import { assert } from "chai";
|
|||
import {
|
||||
formatTime,
|
||||
formatTimeWithSeconds,
|
||||
formatTimeWeekday,
|
||||
} from "../../../src/common/datetime/format_time";
|
||||
import { NumberFormat, TimeFormat } from "../../../src/data/translation";
|
||||
|
||||
|
@ -51,3 +52,26 @@ describe("formatTimeWithSeconds", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatTimeWeekday", () => {
|
||||
const dateObj = new Date(2017, 10, 18, 23, 12, 13, 1400);
|
||||
|
||||
it("Formats English times", () => {
|
||||
assert.strictEqual(
|
||||
formatTimeWeekday(dateObj, {
|
||||
language: "en",
|
||||
number_format: NumberFormat.language,
|
||||
time_format: TimeFormat.am_pm,
|
||||
}),
|
||||
"Wednesday 11:12 PM"
|
||||
);
|
||||
assert.strictEqual(
|
||||
formatTimeWeekday(dateObj, {
|
||||
language: "en",
|
||||
number_format: NumberFormat.language,
|
||||
time_format: TimeFormat.twenty_four,
|
||||
}),
|
||||
"Wednesday 23:12"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue