mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-03-31 07:12:23 -07:00
FE: locale for date formats #1335
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -369,13 +369,15 @@ function getLangCode() {
|
||||
return lang_code;
|
||||
}
|
||||
|
||||
|
||||
const tz = getSetting("TIMEZONE") || 'Europe/Berlin';
|
||||
const LOCALE = getSetting('UI_LOCALE') || 'en-GB';
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// String utilities
|
||||
// -----------------------------------------------------------------------------
|
||||
function localizeTimestamp(input) {
|
||||
let tz = getSetting("TIMEZONE") || 'Europe/Berlin';
|
||||
|
||||
|
||||
input = String(input || '').trim();
|
||||
|
||||
// 1. Unix timestamps (10 or 13 digits)
|
||||
@@ -450,7 +452,7 @@ function localizeTimestamp(input) {
|
||||
console.error(`ERROR: Couldn't parse date: '${str}' with TIMEZONE ${tz}`);
|
||||
return 'Failed conversion - Check browser console';
|
||||
}
|
||||
return new Intl.DateTimeFormat('default', {
|
||||
return new Intl.DateTimeFormat(LOCALE, {
|
||||
timeZone: tz,
|
||||
year: 'numeric', month: '2-digit', day: '2-digit',
|
||||
hour: '2-digit', minute: '2-digit', second: '2-digit',
|
||||
|
||||
@@ -26,6 +26,34 @@
|
||||
],
|
||||
"params": [],
|
||||
"settings": [
|
||||
{
|
||||
"function": "LOCALE",
|
||||
"type": {
|
||||
"dataType": "string",
|
||||
"elements": [
|
||||
{
|
||||
"elementType": "input",
|
||||
"elementOptions": [],
|
||||
"transformers": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"default_value": "en-GB",
|
||||
"options": [],
|
||||
"localized": ["name", "description"],
|
||||
"name": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "Locale"
|
||||
}
|
||||
],
|
||||
"description": [
|
||||
{
|
||||
"language_code": "en_us",
|
||||
"string": "The locale used to format dates that are displayed in the UI."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"function": "NOT_RANDOM_MAC",
|
||||
"type": {
|
||||
|
||||
Reference in New Issue
Block a user