From 16014d662379fc3e7c712514a5b4a96ecc9add43 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Mon, 28 Oct 2024 22:48:51 -0600 Subject: [PATCH] fix timestamp maybe? --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index f5ceb83..2e63597 100644 --- a/index.js +++ b/index.js @@ -102,13 +102,18 @@ function updateRecords(data, root) { return data; } +function getStartOfDayTimestamp(date) { + const startOfDay = new Date(date.getFullYear(), date.getMonth(), date.getDate()); + return startOfDay.getTime(); // Returns the timestamp in milliseconds +} + async function sendSummary() { const data = await getPreviousDayData(); const root = await loadRecords(); const updatedData = await updateRecords(data, root); await saveRecords(root); - const previousDayStart = new Date(Date.now() - 86400000); + const previousDayStart = new Date(getStartOfDayTimestamp(new Date())); const previousDayEnd = new Date(previousDayStart); previousDayEnd.setHours(23, 59, 59, 999);