mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
DateTime format based on TIMEZONE #1044
This commit is contained in:
@@ -173,7 +173,7 @@
|
|||||||
|
|
||||||
// Additional form elements like the random MAC address button for devMac
|
// Additional form elements like the random MAC address button for devMac
|
||||||
let inlineControl = "";
|
let inlineControl = "";
|
||||||
// handle rendom mac
|
// handle random mac
|
||||||
if (setting.setKey == "NEWDEV_devMac" && deviceData["devIsRandomMAC"] == true) {
|
if (setting.setKey == "NEWDEV_devMac" && deviceData["devIsRandomMAC"] == true) {
|
||||||
inlineControl += `<span class="input-group-addon pointer"
|
inlineControl += `<span class="input-group-addon pointer"
|
||||||
title="${getString("RandomMAC_hover")}">
|
title="${getString("RandomMAC_hover")}">
|
||||||
|
|||||||
@@ -47,9 +47,28 @@
|
|||||||
{visible: false, targets: [0]},
|
{visible: false, targets: [0]},
|
||||||
|
|
||||||
// Replace HTML codes
|
// Replace HTML codes
|
||||||
{targets: [1,2,3,5],
|
{targets: [3,5],
|
||||||
'createdCell': function (td, cellData, rowData, row, col) {
|
'createdCell': function (td, cellData, rowData, row, col) {
|
||||||
$(td).html (translateHTMLcodes (cellData));
|
$(td).html (translateHTMLcodes (cellData));
|
||||||
|
} },
|
||||||
|
// Date
|
||||||
|
{targets: [1,2],
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
console.log(cellData);
|
||||||
|
|
||||||
|
if (!cellData.includes("missing event") && !cellData.includes("..."))
|
||||||
|
{
|
||||||
|
if (cellData.includes("+")) { // Check if timezone offset is present
|
||||||
|
cellData = cellData.split('+')[0]; // Remove timezone offset
|
||||||
|
}
|
||||||
|
console.log(cellData);
|
||||||
|
result = localizeTimestamp(cellData);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
result = translateHTMLcodes(cellData)
|
||||||
|
}
|
||||||
|
|
||||||
|
$(td).html (result);
|
||||||
} }
|
} }
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ function initializeDatatable () {
|
|||||||
} },
|
} },
|
||||||
|
|
||||||
// Replace HTML codes
|
// Replace HTML codes
|
||||||
{targets: [3,4,5,6,7],
|
{targets: [4,5,6,7],
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
$(td).html (translateHTMLcodes (cellData));
|
$(td).html (translateHTMLcodes (cellData));
|
||||||
} },
|
} },
|
||||||
@@ -226,6 +226,12 @@ function initializeDatatable () {
|
|||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
// console.log(cellData);
|
// console.log(cellData);
|
||||||
$(td).html (cellData);
|
$(td).html (cellData);
|
||||||
|
} },
|
||||||
|
// Date
|
||||||
|
{targets: [3],
|
||||||
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
|
// console.log(cellData);
|
||||||
|
$(td).html (localizeTimestamp(cellData));
|
||||||
} }
|
} }
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -353,6 +353,28 @@ function getLangCode() {
|
|||||||
// String utilities
|
// String utilities
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
function localizeTimestamp(result)
|
||||||
|
{
|
||||||
|
|
||||||
|
// contains TZ in format Europe/Berlin
|
||||||
|
tz = getSetting("TIMEZONE")
|
||||||
|
|
||||||
|
const date = new Date(result); // Assumes result is a timestamp or ISO string
|
||||||
|
const formatter = new Intl.DateTimeFormat('default', {
|
||||||
|
timeZone: tz,
|
||||||
|
year: 'numeric',
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
second: '2-digit',
|
||||||
|
hour12: false // change to true if you want AM/PM format
|
||||||
|
});
|
||||||
|
|
||||||
|
return formatter.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------
|
// ----------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Replaces double quotes within single-quoted strings, then converts all single quotes to double quotes,
|
* Replaces double quotes within single-quoted strings, then converts all single quotes to double quotes,
|
||||||
|
|||||||
@@ -78,6 +78,9 @@ require 'php/templates/header.php';
|
|||||||
if (result.includes("+")) { // Check if timezone offset is present
|
if (result.includes("+")) { // Check if timezone offset is present
|
||||||
result = result.split('+')[0]; // Remove timezone offset
|
result = result.split('+')[0]; // Remove timezone offset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = localizeTimestamp(result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user