fix: timestamp in wrong timezone after save
This commit is contained in:
parent
290992dfce
commit
403a9634d2
14
index.html
14
index.html
@ -230,6 +230,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
function formatDateToLocalInput(date) {
|
||||||
|
const pad = (n) => n.toString().padStart(2, '0');
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = pad(date.getMonth() + 1);
|
||||||
|
const day = pad(date.getDate());
|
||||||
|
const hours = pad(date.getHours());
|
||||||
|
const minutes = pad(date.getMinutes());
|
||||||
|
return `${year}-${month}-${day}T${hours}:${minutes}`;
|
||||||
|
}
|
||||||
const STORAGE_KEY = 'milkProductionEntries';
|
const STORAGE_KEY = 'milkProductionEntries';
|
||||||
const REMOVED_KEY = 'milkProductionRemoved';
|
const REMOVED_KEY = 'milkProductionRemoved';
|
||||||
|
|
||||||
@ -238,7 +247,7 @@
|
|||||||
|
|
||||||
const listEl = document.getElementById('list');
|
const listEl = document.getElementById('list');
|
||||||
const timestampInput = document.getElementById('timestamp');
|
const timestampInput = document.getElementById('timestamp');
|
||||||
timestampInput.value = new Date().toISOString().slice(0, 16);
|
timestampInput.value = formatDateToLocalInput(new Date());
|
||||||
const amountInput = document.getElementById('amount');
|
const amountInput = document.getElementById('amount');
|
||||||
const submitBtn = document.getElementById('submit-btn');
|
const submitBtn = document.getElementById('submit-btn');
|
||||||
|
|
||||||
@ -404,7 +413,8 @@
|
|||||||
entries.push(newEntry);
|
entries.push(newEntry);
|
||||||
save();
|
save();
|
||||||
render();
|
render();
|
||||||
timestampInput.value = new Date().toISOString().slice(0, 16);
|
|
||||||
|
timestampInput.value = formatDateToLocalInput(new Date());
|
||||||
amountInput.value = '';
|
amountInput.value = '';
|
||||||
updateSubmitState();
|
updateSubmitState();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user