Skip to content

Fix Date Validation in chunkDaysIntoWeeks Function - #8876

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
tmdeveloper007:fix/8844-chunk-days-date-component-validation
Aug 6, 2026
Merged

Fix Date Validation in chunkDaysIntoWeeks Function#8876
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
tmdeveloper007:fix/8844-chunk-days-date-component-validation

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary of What Has Been Done

Replaced the loose regex + new Date() validity check with explicit date component validation. The fix validates that month is 1-12 and uses a days-in-month lookup to reject impossible dates like "2024-02-30".

Changes Made

  • lib/calculate.ts: Added explicit date component validation

Impact it Made

  • Prevents garbage dates from polluting contribution calendar data
  • Makes validation semantically correct

Closes #8844

Note: Please assign this PR to the tmdeveloper007 account.

@retenta-bot

retenta-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

This PR enhances the date validation logic by replacing the previous loose regex and new Date() checks with explicit validation for date components. This change is crucial as it prevents garbage dates from polluting the contribution calendar data, aligning with our previous decisions on improving date validation. Thank you for your contribution!

@retenta-bot retenta-bot Bot changed the title fix : validated date components in chunkDaysIntoWeeks to reject impossible dates Fix Date Validation in chunkDaysIntoWeeks Function Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 4939.27 KB 4939.27 KB 0 B
Total CSS 348.46 KB 348.46 KB 0 B

@Aamod007 Aamod007 added level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected mentor:Aamod007 labels Aug 6, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work on this date validation fix! Using explicit matching and checking the \daysInMonth\ ensures that impossible dates like 2024-02-30 are properly rejected, avoiding bad data from sneaking into the contribution calendar. The transition from a loose regex and generic
ew Date\ to strict validation in \lib/calculate.ts\ is exactly what's needed. Approved!

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Aug 6, 2026
@JhaSourav07
JhaSourav07 merged commit b4efa72 into JhaSourav07:main Aug 6, 2026
20 of 21 checks passed
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix : validate date components in chunkDaysIntoWeeks to reject impossible dates

3 participants