Skip to content

Conversation

@ali-master
Copy link

@ali-master ali-master commented Oct 16, 2025

Summary

This PR adds Persian (fa) locale support to Chrono, enabling natural language date/time parsing for Persian speakers.

Changes

  • Locale implementation: Created fa.casual configuration with Persian date/time expressions
  • Casual expressions: Support for common phrases:
    • Relative dates: "الان", "امروز", "فردا", "دیروز"
    • Time-of-day anchors: "صبح" (06:00), "ظهر" (12:00), "عصر" (18:00)
  • Tests: Added comprehensive unit tests in test/fa/fa_casual.test.ts
  • Exports: Exposed fa locale from root export

Other Changes:

Testing

Run Persian locale tests:

npm run test:silent -- test/fa/*.ts --no-coverage

Usage

import * as chrono from 'chrono-node';

chrono.fa.casual.parse('امروز صبح');
// Returns parsed result for "today morning"

Notes

  • No breaking changes; purely additive
  • Follows existing locale patterns for consistency
  • Future improvements could include Persian digits, weekday/month names, and relative units

…lities

- Add support for optional "این" prefix in casual time expressions.
- Introduce FARelativeDateFormatParser for handling relative date formats.
- Implement FATimeUnitCasualRelativeFormatParser for explicit time units.
- Update FATimeExpressionParser to extract minutes from specific patterns.
- Modify FAWeekdayParser to recognize "این" as a prefix modifier.
- Add `FAWeekdayRangeParser` to support parsing weekday ranges like "از دوشنبه تا جمعه."
- Implement `FAMergeWeekdayDateRefiner` to merge adjacent weekday and date expressions.
- Update `FAWeekdayParser` to prefer current day for same-weekday matches.
- Refactor refiners and parsers for better clarity and extensibility.
- Adjust test cases to align with parser and refiner updates.
- Update `FAStrictModeRefiner` to filter out vague and standalone time expressions like "صبح" and "عصر."
- Enhance `FATimeUnitWithinFormatParser` with stricter pattern matching and tagging for better identification.
- Adjust `FARelativeDateFormatParser` to exclude ambiguous casual expressions like "روز بعد."
- Rearrange parser initialization order in `fa/index.ts` for better processing flow.
Copilot AI review requested due to automatic review settings October 16, 2025 21:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds comprehensive Persian (fa) locale support to Chrono, including parsers/refiners, exports, and extensive tests. Also updates timezone handling for IRST and modernizes tooling/config.

  • New fa locale: Parsers for weekdays, ranges, time units (ago/within/later), month names (SH and Gregorian), casual phrases, and refiners for merging and strict mode.
  • Tests: Extensive unit tests covering Persian expressions, edge cases, and negative cases; minor Jest matcher update.
  • Tooling/Docs: Export fa in root, README updates, eslint flat config, and Jest/TS deps bump.

Reviewed Changes

Copilot reviewed 37 out of 38 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/locales/fa/** New Persian locale implementation (parsers/refiners/constants/config).
test/fa/** New test suites validating Persian parsing behaviors and edge cases.
src/index.ts Exports fa locale.
README.md Documents fa as supported locale and usage example.
src/timezone.ts Changes IRST to DST-aware mapping.
src/results.ts Minor const refactor in relative date creation.
test/debugging.test.ts Updates deprecated Jest matchers.
package.json Bumps Jest/TS/Eslint deps; sets TZ=UTC in scripts; moves eslint config to flat file.
eslint.config.js Introduces ESLint Flat Config.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ali-master
Copy link
Author

Any updates?

@wanasit

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