Skip to content

Dev Use chrono-date for date parsing of forwared mails#22

Merged
dspangenberg merged 4 commits intomainfrom
dev
Apr 2, 2026
Merged

Dev Use chrono-date for date parsing of forwared mails#22
dspangenberg merged 4 commits intomainfrom
dev

Conversation

@dspangenberg
Copy link
Copy Markdown
Owner

@dspangenberg dspangenberg commented Apr 2, 2026

Changes proposed in this pull request:

Fixes #

Checklist:

  • docs updated
  • tests updated
  • Changes.md updated
  • package.json.version bumped

Summary by CodeRabbit

  • New Features

    • Date parsing is now more flexible and supports input in multiple locales, including German, French, Portuguese, Japanese, and Chinese date formats
  • Chores

    • Package version updated to 0.9.1
    • New runtime dependency added: chrono-node

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 2, 2026

Warning

Rate limit exceeded

@dspangenberg has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 58 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 6 minutes and 58 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 339c25ac-f1e8-437f-addb-5627787c1a2f

📥 Commits

Reviewing files that changed from the base of the PR and between 9226d06 and 77add72.

📒 Files selected for processing (1)
  • index.js
📝 Walkthrough

Walkthrough

The pull request replaces the manual date parsing implementation in parseFlexibleDate with the chrono-node library to support multiple locales. Package version bumped to 0.9.1, dependencies updated, and test assertions adjusted accordingly.

Changes

Cohort / File(s) Summary
Version & Dependency Management
CHANGELOG.md, package.json
Version downgraded to 0.9.1, new entry created with "Use chrono-node for flexible date parsing" bullet. Dependency chrono-node@^2.9.0 added.
Date Parsing Implementation
index.js
Replaced manual regex-based date parsing (German/English month names) with chronoParsers array iterating through six locale-aware chrono parsers (chrono, de, fr, pt, ja, zh), returning first result with certain year detection.
Test Updates
test/index.js
Removed assertion validating getHours() === 0 from German date format test case.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Dev #17: Modifies parseFlexibleDate to add German month mapping; main PR replaces manual parsing (including German mapping) with chrono-node's locale parsers.

Poem

🐰 Hops away with dates so bright,
Chrono-node sets parsing right,
German, French, and more in sight,
No more regex in the night!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Dev Use chrono-date for date parsing of forwared mails' is partially related to the changeset but contains inaccuracies and is overly broad; it mentions 'chrono-date' when the actual dependency is 'chrono-node', and 'forwarded' is misspelled as 'forwared'. Clarify the title to accurately reflect the main change: consider 'Use chrono-node for flexible date parsing' or similar, ensuring correct spelling and dependency naming.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
index.js (1)

190-195: Consider edge cases with isCertain('year') check.

The isCertain('year') requirement means dates without an explicit year (e.g., "January 15" or "15. Januar") will be rejected even if the date string is otherwise valid. This is likely intentional for forwarded email parsing where the full date is expected, but worth confirming this behavior is desired.

If relative dates or dates without years should be supported, you could fall back to accepting results where the year is inferred.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.js` around lines 190 - 195, Current loop rejects parsed dates lacking
an explicit year because it only returns when results[0].start.isCertain('year')
is true; update the logic in the loop that iterates chronoParsers and calls
parser.parse(dateStr) so it can optionally accept inferred/relative years: after
parsing (parser.parse and results[0]), check either start.isCertain('year') OR
(a fallback condition such as start.get('year') being present, or a new flag
allowInferredYear) and if that fallback is allowed, accept results[0].date() (or
normalize relative dates using the parser’s reference date) instead of skipping;
change references in this block (chronoParsers, parser.parse,
results[0].start.isCertain('year'), results[0].date()) accordingly so callers
can enable inferred-year behavior when desired.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@index.js`:
- Around line 190-195: Current loop rejects parsed dates lacking an explicit
year because it only returns when results[0].start.isCertain('year') is true;
update the logic in the loop that iterates chronoParsers and calls
parser.parse(dateStr) so it can optionally accept inferred/relative years: after
parsing (parser.parse and results[0]), check either start.isCertain('year') OR
(a fallback condition such as start.get('year') being present, or a new flag
allowInferredYear) and if that fallback is allowed, accept results[0].date() (or
normalize relative dates using the parser’s reference date) instead of skipping;
change references in this block (chronoParsers, parser.parse,
results[0].start.isCertain('year'), results[0].date()) accordingly so callers
can enable inferred-year behavior when desired.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: e944be6f-fd48-482b-a4a0-33ac5eec629b

📥 Commits

Reviewing files that changed from the base of the PR and between 7abd454 and 9226d06.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • index.js
  • package.json
  • test/index.js
💤 Files with no reviewable changes (1)
  • test/index.js

@dspangenberg dspangenberg merged commit 8cba88f into main Apr 2, 2026
8 checks passed
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.

1 participant