diff --git a/source/data/transformer.mjs b/source/data/transformer.mjs index 22ec307c1beb73c44bf0c272cecd167161cfb9c3..af210b3c2d8fbfa4a38cf300ec93b5c84e6bfe66 100644 --- a/source/data/transformer.mjs +++ b/source/data/transformer.mjs @@ -647,10 +647,12 @@ function transform(value) { if (isNaN(date.getTime())) { throw new Error("invalid date"); } - + try { locale = getLocaleOfDocument(); - return date.toLocaleTimeString(locale); + return date.toLocaleTimeString(locale.toString(),{ + hour12: false + }); } catch (e) { throw new Error(`unsupported locale or missing format (${e.message})`); } @@ -663,7 +665,8 @@ function transform(value) { const options = { dateStyle: "medium", - timeStyle: "medium" + timeStyle: "medium", + hour12: false }; if (args.length > 0) { @@ -676,9 +679,6 @@ function transform(value) { try { locale = getLocaleOfDocument().toString(); - - console.log(locale, options, date,"!!!!"); - return new Intl.DateTimeFormat(locale, options).format(date); } catch (e) { throw new Error(`unsupported locale or missing format (${e.message})`); diff --git a/test/cases/data/transformer.mjs b/test/cases/data/transformer.mjs index 1e3e824600f5ee086f6927b4891cbd5d9af099f9..f01085b07876a2cf395c4e7f57e8878bae94dfbb 100644 --- a/test/cases/data/transformer.mjs +++ b/test/cases/data/transformer.mjs @@ -29,9 +29,9 @@ describe('Transformer', function () { describe('Transformer.run()', function () { [ - ['datetimeformat', "2023-02-04 08:02:01", "04.02.2023, 08:02:01"], - ['datetimeformat:long:short', "2023-02-04 08:02:01","4. Februar 2023 um 08:02"], - ['datetimeformat:short:short', "2023-02-04 08:02:01", "04.02.23, 08:02"], + ['datetimeformat', "2023-02-04 08:02:01", "Feb 4, 2023, 08:02:01"], + ['datetimeformat:long:short', "2023-02-04 08:02:01","February 4, 2023 at 08:02"], + ['datetimeformat:short:short', "2023-02-04 08:02:01", "2/4/23, 08:02"], ['equals:a', "a", true], ['equals:a', "b", false], ['equals:3', 3, true],