Fix #324: Handle numeric YAML parsing for startDate/endDate with YYYYMMDD format#539
Open
mikegreiner wants to merge 1 commit intopyrochlore:masterfrom
Open
Conversation
…format Fixes issue pyrochlore#324 where dateFormat: YYYYMMDD made startDate and endDate ineffective, causing all files to be included regardless of date range. Root cause: YAML parsers may parse numeric-looking dates (e.g., 20240201) as numbers instead of strings. The code only checked typeof === 'string', so numeric values were skipped, leaving startDate/endDate as null. Changes: - Updated parsing.ts to handle both string and number types for startDate/endDate, converting numbers to strings before processing - Updated main.ts to use isBefore/isAfter with 'day' granularity for clearer, more readable date comparisons - Fixed closure issue by capturing startDate/endDate in local variables before async file processing loop - Fixed helper.ts bug: changed .contains() to .includes() for string method compatibility Tests: - Added unit tests for YYYYMMDD date format parsing and filtering - Added edge case tests for boundary conditions and missing dates - Added date comparison method tests - All 28 tests passing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #324 - Fixes issue where
dateFormat: YYYYMMDDmadestartDateandendDateineffective, causing all files to be included regardless of the date range.Root cause: YAML parsers may parse numeric-looking dates (e.g.,
20240201) as numbers instead of strings. The code only checkedtypeof === 'string', so numeric values were skipped, leavingstartDate/endDateasnull.Changes
parsing.tsto handle both string and number types forstartDate/endDate, converting numbers to strings before processingmain.tsto useisBefore/isAfterwith 'day' granularity for clearer, more readable date comparisonsstartDate/endDatein local variables before async file processing loophelper.tsbug: changed.contains()to.includes()for string method compatibilityType of Change
How Has This Been Tested?
test/date-format-yyyymmdd.test.ts) - 10 tests for date parsing and comparisontest/parsing-yyyymmdd.test.ts) - 4 tests for YAML parsing with YYYYMMDD formattest/edge-cases-date-filtering.test.ts) - 8 tests for boundary conditions, missing dates, year/month boundariestest/date-comparison-methods.test.ts) - 6 tests comparing different date comparison approachesDocumentation
Related Issue
Closes #324