From 03fb4045dc6114c5d7027efdc33c8af759b1b1c0 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Sun, 11 Jan 2026 18:46:37 +0100 Subject: [PATCH] JS/Date * add localeaware Date.getLocaleDay method and reorder week days array * calendars should now have a region approriate first day of the week --- setup/sql/updates/1768155583_01.sql | 1 + setup/tools/filegen/templates/global.js/0_user.js | 15 +++++++++++++++ .../tools/filegen/templates/global.js/listview.js | 2 +- static/js/locale_dede.js | 2 +- static/js/locale_eses.js | 2 +- static/js/locale_frfr.js | 2 +- static/js/locale_ruru.js | 2 +- 7 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 setup/sql/updates/1768155583_01.sql diff --git a/setup/sql/updates/1768155583_01.sql b/setup/sql/updates/1768155583_01.sql new file mode 100644 index 00000000..03adf418 --- /dev/null +++ b/setup/sql/updates/1768155583_01.sql @@ -0,0 +1 @@ +UPDATE `aowow_dbversion` SET `build` = CONCAT(IFNULL(`build`, ''), ' globaljs'); diff --git a/setup/tools/filegen/templates/global.js/0_user.js b/setup/tools/filegen/templates/global.js/0_user.js index 7202a369..cb968339 100644 --- a/setup/tools/filegen/templates/global.js/0_user.js +++ b/setup/tools/filegen/templates/global.js/0_user.js @@ -3,6 +3,21 @@ 'abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video'.replace(/\w+/g,function(n){document.createElement(n)}) +// aowow - extend Date for holidaycal +Date.prototype.getLocaleDay = function() { + const dayNo = this.getDay(); + switch (Locale.getId()) + { + case LOCALE_FRFR: + case LOCALE_DEDE: + case LOCALE_ESES: + case LOCALE_RURU: + return !dayNo ? 6 : dayNo - 1; + default: + return dayNo; + } +}; + /* User-related functions TODO: Move global variables/functions into User class diff --git a/setup/tools/filegen/templates/global.js/listview.js b/setup/tools/filegen/templates/global.js/listview.js index 7942ba64..476c2a04 100644 --- a/setup/tools/filegen/templates/global.js/listview.js +++ b/setup/tools/filegen/templates/global.js/listview.js @@ -1098,7 +1098,7 @@ Listview.prototype = { $WH.ae(this.tbody, tr); tr = $WH.ce('tr'); - for (var k = 0; k < this.dates[starti].date.getDay(); ++k) + for (var k = 0; k < this.dates[starti].date.getLocaleDay(); ++k) { var foo = $WH.ce('td'); foo.className = 'empty-cell'; diff --git a/static/js/locale_dede.js b/static/js/locale_dede.js index deecf7a8..d4bea2c6 100644 --- a/static/js/locale_dede.js +++ b/static/js/locale_dede.js @@ -2553,7 +2553,7 @@ var LANG = { date_simple: "$1.$2.$3", unknowndate_stc: "Unbekanntes Datum", date_months: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"], - date_days: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"], + date_days: ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"], amount: "Menge", abilities: "Fähigkeiten", diff --git a/static/js/locale_eses.js b/static/js/locale_eses.js index def2aa9d..2bcea8a7 100644 --- a/static/js/locale_eses.js +++ b/static/js/locale_eses.js @@ -2553,7 +2553,7 @@ var LANG = { date_simple: "$1/$2/$3", unknowndate_stc: "Fecha desconocida", date_months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"], - date_days: ["Domingo", "Lunes", "Martes", "Jueves", "Jueves", "Viernes", "Sábado"], + date_days: ["Lunes", "Martes", "Jueves", "Jueves", "Viernes", "Sábado", "Domingo"], amount: "Cantidad", abilities: "Habilidades", diff --git a/static/js/locale_frfr.js b/static/js/locale_frfr.js index fc51fa89..0dd922c2 100644 --- a/static/js/locale_frfr.js +++ b/static/js/locale_frfr.js @@ -2553,7 +2553,7 @@ var LANG = { date_simple: "$1-$2-$3", unknowndate_stc: "Date inconnue", date_months: ["janvier", "février", "mars", "Avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"], - date_days: ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"], + date_days: ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"], amount: "Montant", abilities: "Techniques", diff --git a/static/js/locale_ruru.js b/static/js/locale_ruru.js index 12622b1b..e3cb937c 100644 --- a/static/js/locale_ruru.js +++ b/static/js/locale_ruru.js @@ -2553,7 +2553,7 @@ var LANG = { date_simple: "$1.$2.$3", unknowndate_stc: "Неизвестная дата", date_months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"], - date_days: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"], + date_days: ["Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"], amount: "Количество", abilities: "Способности",