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:
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user