diff --git a/src/DailyFiles.js b/src/DailyFiles.js index d67671a38..57825c527 100644 --- a/src/DailyFiles.js +++ b/src/DailyFiles.js @@ -78,8 +78,8 @@ function newDailyFiles () { case GLOBAL.DEFAULT_OK_RESPONSE.result: { if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> Received OK Response.') } - beginDateRange = new Date(pFile.begin) - endDateRange = new Date(pFile.end) + beginDateRange = pFile.begin + endDateRange = pFile.end break } @@ -141,23 +141,20 @@ function newDailyFiles () { switch (err.result) { case GLOBAL.DEFAULT_OK_RESPONSE.result: { - - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received OK Response.') } - break - } + if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received OK Response.') } + break + } case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { - - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received FAIL Response.') } - callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } + if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received FAIL Response.') } + callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } default: { - - if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received Unexpected Response.') } - callBackWhenFileReceived(err) - return - } + if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileReceived -> onInitialized -> Received Unexpected Response.') } + callBackWhenFileReceived(err) + return + } } fileCursors.set(periodTime, fileCursor) diff --git a/src/FileCursor.js b/src/FileCursor.js index 87a653a8d..febf86343 100644 --- a/src/FileCursor.js +++ b/src/FileCursor.js @@ -66,7 +66,7 @@ function newFileCursor () { bot = pBot thisSet = pSet periodName = pPeriodName - cursorDate = pCursorDate + cursorDate = removeTime(pCursorDate) timePeriod = pTimePeriod beginDateRange = pBeginDateRange endDateRange = pEndDateRange @@ -194,7 +194,7 @@ function newFileCursor () { */ - cursorDate = pDatetime // Adjust the cursor date to the one received. + cursorDate = removeTime(pDatetime) // Adjust the cursor date to the one received. let positionA @@ -396,7 +396,7 @@ function newFileCursor () { return } - cursorDate = pDatetime + cursorDate = removeTime(pDatetime) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] setDatetime -> err = ' + err.stack) } } @@ -445,29 +445,21 @@ function newFileCursor () { } } - let compareTargetDate = new Date(targetDate.toDateString()) + let compareTargetDate = new Date(targetDate.valueOf()) if (beginDateRange !== undefined) { - let compareBeginDate = new Date(beginDateRange.toDateString()) - - if (compareTargetDate.valueOf() < compareBeginDate.valueOf()) { - if (INFO_LOG === true) { logger.write('[INFO] getFiles -> getNextFile -> compareTargetDate < compareBeginDate -> Not loading the file for this date.') } - if (INFO_LOG === true) { logger.write('[INFO] getFiles -> getNextFile -> compareTargetDate < compareBeginDate -> compareTargetDate = ' + compareTargetDate) } - if (INFO_LOG === true) { logger.write('[INFO] getFiles -> getNextFile -> compareTargetDate < compareBeginDate -> compareBeginDate = ' + compareBeginDate) } + let compareBeginDate = beginDateRange + if (compareTargetDate.valueOf() < compareBeginDate) { controlLoop() return } } if (endDateRange !== undefined) { - let compareEndDate = new Date(endDateRange.toDateString()) - - if (compareTargetDate.valueOf() > compareEndDate.valueOf()) { - if (INFO_LOG === true) { logger.write('[INFO] getFiles -> getNextFile -> compareTargetDate > compareEndDate -> Not loading the file for this date.') } - if (INFO_LOG === true) { logger.write('[INFO] getFiles -> getNextFile -> compareTargetDate > compareEndDate -> compareTargetDate = ' + compareTargetDate) } - if (INFO_LOG === true) { logger.write('[INFO] getFiles -> getNextFile -> compareTargetDate > compareEndDate -> compareEndDate = ' + compareEndDate) } + let compareEndDate = endDateRange + if (compareTargetDate.valueOf() > compareEndDate) { controlLoop() return }