Skip to content

Commit

Permalink
Adjust report timestamps by current timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpp committed Dec 23, 2024
1 parent 6769fca commit 7ddd89e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions webroot/html/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,14 @@ <h5 class="titleHeader">
window.addEventListener("load", () => {
const oneYearAgo = new Date(Date.now() - (365 * 24 * 60 * 60 * 1000));
const now = new Date();
const tzOffset = now.getTimezoneOffset() * 60 * 1000;

document.querySelector("#export-start-date").value = oneYearAgo.toISOString().slice(0,10);
document.querySelector("#export-end-date").value = now.toISOString().slice(0,10);

document.querySelector("#export-form").addEventListener("submit", () => {
document.querySelector("#export-start-date-ts").value = Math.floor(document.querySelector("#export-start-date").valueAsNumber / 1000);
document.querySelector("#export-end-date-ts").value = Math.floor(document.querySelector("#export-end-date").valueAsNumber / 1000);
document.querySelector("#export-start-date-ts").value = Math.floor((document.querySelector("#export-start-date").valueAsNumber + tzOffset) / 1000);
document.querySelector("#export-end-date-ts").value = Math.floor((document.querySelector("#export-end-date").valueAsNumber + tzOffset) / 1000);
});
});
</script>
Expand Down

0 comments on commit 7ddd89e

Please sign in to comment.