Skip to content

Conversation

@RexSkz
Copy link
Collaborator

@RexSkz RexSkz commented Mar 3, 2025

Fix an edge case

There will be a panic when m.Left == -1, this is the root cause of this issue.

The reason why m.Left == -1 is due to the exact_month_date rule that returns an empty string for 这周三 (this Wednesday).

But simply fixing this issue will cause another issue ↓

Fix Chinese exact_month_date rule

The previous regex will recognise 2下周天 as 2.

  • This is "a normal number 2 and next Sunday", which should be next Sunday, since 2 is meaningless here.
  • A regex will match 2, which is wrong.
  • I separated the "number-only form" from the "number & Chinese character form" to fix this issue.
  • To prevent the regex from returning an empty string, the "number-only form" should be placed first.

Close #47

@RexSkz RexSkz requested a review from olebedev as a code owner March 3, 2025 15:15
Copy link
Owner

@olebedev olebedev left a comment

Choose a reason for hiding this comment

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

Thanks @RexSkz 👍 LGTM

@olebedev olebedev merged commit aa16b8b into master Mar 3, 2025
6 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.

Parse Chinese Time Error

3 participants