Skip to content

Conversation

@mikegreiner
Copy link

Description

Fixes #324 - Fixes issue where dateFormat: YYYYMMDD made startDate and endDate ineffective, 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 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

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Added unit tests (test/date-format-yyyymmdd.test.ts) - 10 tests for date parsing and comparison
  • Added parsing tests (test/parsing-yyyymmdd.test.ts) - 4 tests for YAML parsing with YYYYMMDD format
  • Added edge case tests (test/edge-cases-date-filtering.test.ts) - 8 tests for boundary conditions, missing dates, year/month boundaries
  • Added comparison method tests (test/date-comparison-methods.test.ts) - 6 tests comparing different date comparison approaches
  • All 28 tests passing
  • Tested manually in Obsidian with YYYYMMDD format - date filtering now works correctly
  • Tested multi-year date ranges - confirmed correct behavior across year boundaries
  • Verified backward compatibility - YYYY-MM-DD format still works as before

Documentation

  • Documentation update not required (bug fix only, no API changes)

Related Issue

Closes #324

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date format(YYYYMMDD) not working properly for start/end Date

1 participant