Skip to content

"Day keyword + relative time" combined expressions don't work in Portuguese, Japanese, or Chinese #40

Description

@Amato21

Context

PR #39 fixed getParsedDateResult() picking the wrong candidate when chrono-node returns multiple disjoint matches for one string (e.g. English "today in 3 minutes" / French "aujourd'hui dans 3 minutes" used to give the right date but the current time instead of +3 minutes).

That fix generalizes automatically to most languages since the root cause (only ever checking results[0]) was language-agnostic. Verified across all 11 supported languages:

Works correctly (+3 min): English, French, Spanish, Italian, Russian, Ukrainian, German, Dutch.

Does not work: Portuguese, Japanese, Chinese.

Root cause (different from PR #39's bug)

For these 3 languages, chrono-node's own locale parser doesn't recognize the relative-time portion of the combined phrase as a match at all — verified with raw chrono-node calls:

chrono.pt.casual.parse('hoje em 3 minutos', ...)   // -> only "hoje", "em 3 minutos" is dropped entirely
chrono.ja.casual.parse('今日あと3分', ...)           // -> only "今日", "あと3分" is dropped entirely
chrono.zh.hant.casual.parse('今天在3分鐘', ...)      // -> only "今天", "在3分鐘" is dropped entirely

Since chrono-node itself only ever returns one candidate for these languages, PR #39's fix (comparing every candidate to pick the best one) has nothing to choose between — there's no second, better candidate to find.

Possible fix

Build a dedicated custom regex pattern for "day keyword + relative time" (similar to the existing regexWeekdayWithTime pattern for "next Monday at 3pm"), generated per-language via TranslationCollector, instead of relying on chrono-node's fallback for this specific combination. This would make the behavior consistent across all languages instead of depending on chrono-node's per-locale completeness.

Scope note

Standalone "in 3 minutes" (no day keyword) already works correctly in every language — this only affects the combined phrasing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions