From 07c5419a823cdf7be394c4c96088293e53c4ed32 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 10 Dec 2021 13:21:44 -0500 Subject: [PATCH] LibJS: Add test case for locales which do not define day periods Some locales do not define morning, night, etc. day period ranges. TR-35 states they should fall back to the fixed day periods AM and PM. Add a test case for the "as" locale, which is one such locale, to ensure its AM/PM symbols are used. --- .../DateTimeFormat.prototype.format.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.format.js b/Userland/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.format.js index 368a6fd5e6..fda51cb721 100644 --- a/Userland/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.format.js +++ b/Userland/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.format.js @@ -229,9 +229,9 @@ describe("day", () => { describe("dayPeriod", () => { // prettier-ignore const data = [ - { dayPeriod: "narrow", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ صباحًا" }, - { dayPeriod: "short", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ ص" }, - { dayPeriod: "long", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ صباحًا" }, + { dayPeriod: "narrow", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ صباحًا", as0: "অপৰাহ্ন ৫", as1: "পূৰ্বাহ্ন ৭"}, + { dayPeriod: "short", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ ص", as0: "অপৰাহ্ন ৫", as1: "পূৰ্বাহ্ন ৭"}, + { dayPeriod: "long", en0: "5 in the afternoon", en1: "7 in the morning", ar0: "٥ بعد الظهر", ar1: "٧ صباحًا", as0: "অপৰাহ্ন ৫", as1: "পূৰ্বাহ্ন ৭"}, ]; test("all", () => { @@ -251,6 +251,14 @@ describe("dayPeriod", () => { }); expect(ar.format(d0)).toBe(d.ar0); expect(ar.format(d1)).toBe(d.ar1); + + const as = new Intl.DateTimeFormat("as", { + dayPeriod: d.dayPeriod, + hour: "numeric", + timeZone: "UTC", + }); + expect(as.format(d0)).toBe(d.as0); + expect(as.format(d1)).toBe(d.as1); }); }); });