From 2afefb8048ed6f185313b9e9752f427bfbc0f61f 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 --- 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 98dac6a8..a9432945 100644 --- a/src/filters/time-set.js +++ b/src/filters/time-set.js @@ -33,6 +33,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.t('January'), @@ -49,7 +52,24 @@ export function getMonthNameByNumber (monthNumber) { i18n.global.t('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) { @@ -139,7 +159,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