diff --git a/src/app.js b/src/app.js index 7d8ca9c..36dca93 100644 --- a/src/app.js +++ b/src/app.js @@ -1274,6 +1274,10 @@ let pendingType = null; let notePhotoBlob = null; // pending blob for the dialog (not yet committed) let notePhotoURL = null; // current preview object URL + // Whether the user has manually touched the date/time fields. While false the + // dialog logs at the exact current millisecond rather than the minute-floored + // input, so a just-logged event doesn't look up to ~59s old. + let noteTimeEdited = false; function clearNotePhoto() { notePhotoBlob = null; @@ -1288,6 +1292,7 @@ function openNoteDialog(type) { pendingType = type; noteInput.value = ""; + noteTimeEdited = false; const now = Date.now(); noteDate.value = toDateInput(now); noteTime.value = toTimeInput(now); @@ -1301,6 +1306,9 @@ } function noteDialogAt() { + // Untouched time → stamp the exact current instant (sub-minute accurate). + // Once the user picks a time, honor the input (minute precision is fine). + if (!noteTimeEdited) return Date.now(); const parsed = fromDateTimeInputs(noteDate.value, noteTime.value); return Number.isFinite(parsed) ? parsed : Date.now(); } @@ -1309,6 +1317,13 @@ const now = Date.now(); noteDate.value = toDateInput(now); noteTime.value = toTimeInput(now); + noteTimeEdited = false; // "Now" means log at the current instant again + }); + + [noteDate, noteTime].forEach(el => { + const markEdited = () => { noteTimeEdited = true; }; + el.addEventListener("change", markEdited); + el.addEventListener("input", markEdited); }); notePhotoBtn.addEventListener("click", () => notePhotoInput.click());