Use Denver local time for scrape dates instead of UTC

Change default SCRAPER_TIMEZONE from UTC to America/Denver so that
scrape date records (date_checked, daily summaries) reflect local time.
A late-night manual scrape and early-morning automated scrape will no
longer both report as the same UTC day.

Updated getTodayUTC/getTodayDateUTC helpers to use toLocaleDateString
with the configured timezone. ISO timestamps for last_scraped, first_seen,
startedAt etc. remain in UTC as they represent precise moments.
This commit is contained in:
2026-02-09 12:06:50 -07:00
parent 40b4dc50f1
commit 4fb7bf833e
4 changed files with 17 additions and 17 deletions

View File

@ -626,11 +626,11 @@ async function updateDailySummary(db, summaryData, logger) {
// ============================================================
/**
* Get today's date in YYYY-MM-DD format (UTC).
* Get today's date in YYYY-MM-DD format using the configured timezone.
* @returns {string} Today's date string
*/
function getTodayUTC() {
return new Date().toISOString().split('T')[0];
function getToday() {
return new Date().toLocaleDateString('en-CA', { timeZone: config.SCRAPER_TIMEZONE });
}
/**
@ -820,7 +820,7 @@ async function runScrape(db, options = {}) {
result.unitsProcessed = units.length;
// Step 4: Database operations
const today = getTodayUTC();
const today = getToday();
// Get yesterday's unit codes for comparison
const yesterdayUnits = await getYesterdayUnitCodes(db, today);
@ -904,7 +904,7 @@ module.exports = {
recordScraperRun,
createScraperIndexes,
// Export helpers for testing
getTodayUTC,
getToday,
getYesterdayUnitCodes,
getYesterday,
parseInteger,