From f046ffdd0ac3bc157f2dea54d4ce9f7f5081cbf1 Mon Sep 17 00:00:00 2001 From: Yaro Kasear Date: Thu, 10 Jul 2025 08:17:52 -0500 Subject: [PATCH] Add timestamp formatting for updates in worklog template --- inventory/templates/worklog.html | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/inventory/templates/worklog.html b/inventory/templates/worklog.html index 4b43f27..c30d016 100644 --- a/inventory/templates/worklog.html +++ b/inventory/templates/worklog.html @@ -121,6 +121,7 @@ + {% endblock %} {% block script %} @@ -128,6 +129,12 @@ const deleteButton = document.getElementById("deleteButton"); const addUpdateButton = document.getElementById("addUpdateButton"); + function formatDate(date) { + const pad = (n) => String(n).padStart(2, '0'); + return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` + + `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`; + } + if (addUpdateButton) { addUpdateButton.addEventListener("click", (e) => { const row = document.createElement("div"); @@ -142,7 +149,7 @@ // Timestamp span (just display the current time) const ts = document.createElement("span"); ts.classList.add("input-group-text"); - const now = new Date().toLocaleString(); // you could go full ISO if you're feeling spicy + const now = formatDate(new Date()); ts.textContent = now; // Textarea for update content