Hi, I am trying to change the preset managers date format based on salesforce locale setting.
currently, I'm only trying to do it for US, UK and Japan.
The time axis formats are successfully changing for japan and us but uk i get time axis error.
Sample code.
export const localeDateFormat = {
'ja-JP': {
dateFormat: 'YYYY/MM/DD',
bottomDateFormat: 'MM/DD (ddd)',
},
'en-US': {
dateFormat: 'MM/DD/YYYY',
bottomDateFormat: 'MM/DD (ddd)',
},
'en-GB' : {
dateFormat : 'DD/MM/YYYY',
bottomDateFormat : 'MM/DD (ddd)'
}
};
// inside the rendered call back in of lwc component.
// LOCALE is users locale in salesforce.
const currentLocaleName = bryntum.gantt.LocaleHelper.localeName;
const currentLocale = bryntum.gantt.LocaleHelper.locales[currentLocaleName];
const dateLocale = this._getDateFormat(LOCALE);
const mergedLocale = bryntum.gantt.LocaleHelper.mergeLocales(currentLocale, dateLocale);
bryntum.gantt.LocaleManager.applyLocale(LOCALE, mergedLocale);
bryntum.schedulerpro.LocaleManager.applyLocale(LOCALE, mergedLocale);
_getDateFormat(locale) {
const currentLocaleDateFormat = localeDateFormat[locale];
return {
DateHelper: {
formats: {
L: (date) => {
return bryntum.gantt.DateHelper.format(date, currentLocaleDateFormat.dateFormat);
},
ll: (date) => {
return bryntum.gantt.DateHelper.format(date, currentLocaleDateFormat.dateFormat);
},
},
},
PresetManager: {
secondAndMinute: {
displayDateFormat: 'll LTS',
},
minuteAndHour: {
topDateFormat: 'hA',
displayDateFormat: 'll LST',
},
hourAndDay: {
topDateFormat: currentLocaleDateFormat.bottomDateFormat,
middleDateFormat: 'LST',
displayDateFormat: 'll LST',
},
weekAndDay: {
topDateFormat: currentLocaleDateFormat.dateFormat,
bottomDateFormat: currentLocaleDateFormat.bottomDateFormat,
displayDateFormat: 'll LST',
},
dayAndWeek: {
topDateFormat: currentLocaleDateFormat.dateFormat,
displayDateFormat: 'll LST',
},
weekAndDayLetter: {
topDateFormat: currentLocaleDateFormat.dateFormat,
},
},
};
}
This is the error i get when i change the locale to United Kingdom
do you have an idea why this might be happening ?