From 56ca676ead530fd421902da578020cf550a20f46 Mon Sep 17 00:00:00 2001 From: Debora Crescenzo Date: Wed, 20 Aug 2025 15:48:12 +0100 Subject: [PATCH] MT#63428 align day and month values with admin-ui MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the arrays for weekdays and months didn’t match the values used in admin-ui (Sunday=1, Saturday=7, January=1, December=12). This commit updates the calculation function to match admin-ui conventions, ensuring consistency since the data originates from the admin panel and is read-only here. Change-Id: I121c18ffb901beaece19124865b88259ffcb2d3f (cherry picked from commit 2afefb8048ed6f185313b9e9752f427bfbc0f61f) (cherry picked from commit 4f52bf95e58f7e3c321ac4e05169c705a59a68c2) --- src/filters/time-set.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/filters/time-set.js b/src/filters/time-set.js index 9b0943b7..e12a3847 100644 --- a/src/filters/time-set.js +++ b/src/filters/time-set.js @@ -34,6 +34,9 @@ export function getDayNameByNumber (dayNumber, isShortName = false) { return isShortName ? daysShortNamesMap[dayNumber] : daysNamesMap[dayNumber] } +// This logic is aligned with admin-ui where +// * January has value 1 +// * December has value 12 export function getMonthNameByNumber (monthNumber) { const monthsNamesMap = [ i18n.global.tc('January'), @@ -50,7 +53,24 @@ export function getMonthNameByNumber (monthNumber) { i18n.global.tc('December') ] - return monthsNamesMap[monthNumber] + return monthsNamesMap[monthNumber - 1] +} + +// This logic is aligned with admin-ui where +// * Sunday has value 1 +// * Saturday has value 7 +function getWeekDayByNumber (dayNumber) { + const daysNamesMap = [ + i18n.global.t('Sunday'), + i18n.global.t('Monday'), + i18n.global.t('Tuesday'), + i18n.global.t('Wednesday'), + i18n.global.t('Thursday'), + i18n.global.t('Friday'), + i18n.global.t('Saturday') + ] + + return daysNamesMap[dayNumber - 1] } export function timeSetDateExact (times) { @@ -142,7 +162,7 @@ function formatTimeSetValues (timeSetMap, type) { return { year: timeSetMap.year[type] || defaultYear, month: getMonthNameByNumber(timeSetMap.month[type]) || defaultMonth, - wDay: getDayNameByNumber(timeSetMap.wday[type]) ? `${getDayNameByNumber(timeSetMap.wday[type])},` : '', + wDay: getWeekDayByNumber(timeSetMap.wday[type]) || '', mDay: timeSetMap.mday[type] || defaultDay, hour: formatTime(timeSetMap.hour[type]) || defaultTime, minutes: formatTime(timeSetMap.minute[type]) || defaultTime