Add timestamp formatting for updates in worklog template

This commit is contained in:
Yaro Kasear 2025-07-10 08:17:52 -05:00
parent 3df70c15ee
commit f046ffdd0a

View file

@ -121,6 +121,7 @@
</div> </div>
</div> </div>
</nav> </nav>
{% endblock %} {% endblock %}
{% block script %} {% block script %}
@ -128,6 +129,12 @@
const deleteButton = document.getElementById("deleteButton"); const deleteButton = document.getElementById("deleteButton");
const addUpdateButton = document.getElementById("addUpdateButton"); 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) { if (addUpdateButton) {
addUpdateButton.addEventListener("click", (e) => { addUpdateButton.addEventListener("click", (e) => {
const row = document.createElement("div"); const row = document.createElement("div");
@ -142,7 +149,7 @@
// Timestamp span (just display the current time) // Timestamp span (just display the current time)
const ts = document.createElement("span"); const ts = document.createElement("span");
ts.classList.add("input-group-text"); 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; ts.textContent = now;
// Textarea for update content // Textarea for update content