WEB-693: Implement Date and Datetime Global Variables (#3123)

Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
This commit is contained in:
Krishna Mewara
2026-02-15 15:35:42 -06:00
committed by GitHub
parent f60057ae0a
commit 2317e5009c
25 changed files with 290 additions and 50 deletions
+33 -2
View File
@@ -39,6 +39,10 @@ export class SettingsService {
localStorage.setItem('mifosXDateFormat', JSON.stringify(dateFormat));
}
setDatetimeFormat(datetimeFormat: string) {
localStorage.setItem('mifosXDatetimeFormat', JSON.stringify(datetimeFormat));
}
/**
* Sets language setting throughout the app.
* @param {any} language Language.
@@ -112,10 +116,37 @@ export class SettingsService {
}
/**
* Returns date format setting.
* Returns date format setting with fallback precedence:
* 1. User setting (localStorage)
* 2. Global env var
* 3. Hardcoded default
*/
get dateFormat() {
return JSON.parse(localStorage.getItem('mifosXDateFormat'));
const userSetting = localStorage.getItem('mifosXDateFormat');
if (userSetting) {
return JSON.parse(userSetting);
}
if (environment.defaultFormatDate) {
return environment.defaultFormatDate;
}
return 'dd MMMM yyyy';
}
/**
* Returns datetime format setting with fallback precedence:
* 1. User setting (localStorage)
* 2. Global env var
* 3. Hardcoded default
*/
get datetimeFormat() {
const userSetting = localStorage.getItem('mifosXDatetimeFormat');
if (userSetting) {
return JSON.parse(userSetting);
}
if (environment.defaultFormatDatetime) {
return environment.defaultFormatDatetime;
}
return 'dd MMMM yyyy HH:mm:ss';
}
/**