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);