According to the docs it should be possible to format a ZonedDateTime with a weekday in several languages:
I try to show the weekday, for example Montag, Dienstag, …
rules.JSRule({
name: "JS test rule",
description:
"module /opt/openhab/conf/automation/js/node_modules/@js-joda/locale_de-de/dist/js-joda-locale",
triggers: [triggers.ItemStateChangeTrigger("Test3_Switch", "ON")],
execute: (event) => {
let Locale = require("@js-joda/locale_de-de").Locale.GERMAN;
let formatter = time.DateTimeFormatter.ofPattern(
"EEEE, dd.MM.yyyy HH:mm"
).withLocale(Locale);
let result = formatter.format(time.ZonedDateTime.now());
console.debug("result=" + result);
},
tags: [],
});
It gives me an error:
2025-01-23 20:32:01.474 [ERROR] [org.openhab.extra.test.js ] - Failed to execute rule JS-test-rule-58777b4c-f706-4e58-bbd9-b2449fffc7ea: IllegalArgumentException: Pattern using (localized) text not implemented, use @js-joda/locale plugin!: IllegalArgumentException: Pattern using (localized) text not implemented, use @js-joda/locale plugin!
at i (@openhab-globals.js:2)
at appendText (@openhab-globals.js:2)
at _parseField (@openhab-globals.js:2)
at _parsePattern (@openhab-globals.js:2)
at appendPattern (@openhab-globals.js:2)
at ofPattern (@openhab-globals.js:2)
at execute (test.js:15)
at execute (@openhab-globals.js:2)
npm is installed, so is the locale via npm install @js-joda/locale_de-de:
sihui@openhab:/opt/openhab/conf/automation/js/node_modules/@js-joda/locale_de-de/dist$ ls -l
insgesamt 1380
-rw-r--r-- 1 openhab openhab 328271 20. Jan 15:00 index.esm.js
-rw-r--r-- 1 openhab openhab 263014 20. Jan 15:00 index.esm.js.map
-rw-r--r-- 1 openhab openhab 359050 20. Jan 15:00 index.js
-rw-r--r-- 1 openhab openhab 263104 20. Jan 15:00 index.js.map
-rw-r--r-- 1 openhab openhab 180615 20. Jan 15:00 index.min.js
-rw-r--r-- 1 openhab openhab 2328 20. Jan 15:00 js-joda-locale.d.ts