Skip to content

Parse "fortnight" and "century" in English relative dates - #1539

Merged
serhii73 merged 3 commits into
scrapinghub:masterfrom
yamilmaud:fix_DC-1342_Add_support_for_decade_fortnight_century
Oct 20, 2026
Merged

serhii73 merged 3 commits into
scrapinghub:masterfrom
yamilmaud:fix_DC-1342_Add_support_for_decade_fortnight_century

Conversation

@yamilmaud

@yamilmaud yamilmaud commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #725.

"decade" was already supported; this adds the other two words from the issue, for English only.

New words

Unit Words Meaning
fortnight fortnight, fortnights 2 weeks
century century, centuries 100 years

CLDR has no data for these words (it has no decade, century or fortnight field), so they are added to the supplementary English YAML and en.py is regenerated from it.

Supported phrases

Form Fortnight Century
Number plus unit 2 fortnights, a fortnight 2 centuries, a century
Past 2 fortnights ago, a fortnight ago 2 centuries ago, a century ago
Future in a fortnight, in 2 fortnights in a century, in two centuries
Relative last fortnight, this fortnight, next fortnight last century, this century, next century
Later a fortnight later, two fortnights later a century later, 2 centuries later
From now a fortnight from now 2 centuries from now
Combined 1 fortnight 3 days ago 1 century 2 decades ago

These also work with number words (two), decimals (1.5 centuries ago), signs (+1 century) and a trailing time (in a fortnight at 5pm).

Other changes

  • from now / in for decades: a decade from now and in 1 decade resolved to the past, because the in was dropped. Decade, fortnight and century are now in the unit list of Locale._clear_future_words, so these resolve to the future.
  • Ordinal guard: 20th century, the 21st century, 1st century and 2nd fortnight return None. Without the guard the ordinal suffix is a skip word, so 20th century was read as 20 centuries ago (and search_dates read "in the 20th century" as year 4026).

Not covered

  • Bare fortnight ago (no number) and in a fortnight's time, which also fail for week and decade.

  • half a century ago.

  • this century and this fortnight resolve to the past, matching the existing this decade.

  • Ordinals before the older units (3rd decade, 3rd week) are still read as relative dates, as before.

  • Languages other than English.

  • I have read the contributing guide and set up pre-commit.

πŸ€– Generated with Claude Code

Fold a fortnight into 2 weeks and a century into 100 years, like decades.
Also keep the "in" of future expressions ("a decade from now") when the
unit is a decade, fortnight or century.

Refs scrapinghub#725

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the spam label Oct 6, 2026
@github-actions github-actions Bot closed this Oct 6, 2026
@codspeed

codspeed Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

βœ… 7 untouched benchmarks


Comparing yamilmaud:fix_DC-1342_Add_support_for_decade_fortnight_century (8b3b8f7) with master (fed9cf9)

Open in CodSpeed

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 98.97%. Comparing base (fed9cf9) to head (8b3b8f7).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1539   +/-   ##
=======================================
  Coverage   98.96%   98.97%           
=======================================
  Files         239      239           
  Lines        3592     3594    +2     
=======================================
+ Hits         3555     3557    +2     
  Misses         37       37           

β˜” View full report in Codecov by Harness.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AdrianAtZyte AdrianAtZyte reopened this Oct 6, 2026
@AdrianAtZyte AdrianAtZyte removed the spam label Oct 6, 2026
yamilmaud and others added 2 commits October 6, 2026 16:13
The "later" simplification only allowed "century" plus an optional "s",
so "2 centuries later" was not recognised.

Refs scrapinghub#725

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The ordinal suffix is a skip word, so "20th century" was translated to
"20 century" and parsed as 20 centuries ago (and "in the 20th century"
in search_dates as 20 centuries ahead).

Refs scrapinghub#725

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@AdrianAtZyte
AdrianAtZyte requested a review from serhii73 October 13, 2026 12:35

@serhii73 serhii73 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.

Reviewed the diff and ran the full suite on this branch merged with current master (24809 passed); CI is green. The century and fortnight handling folds into years and weeks consistently, and the ordinal guard (20th century) is covered by tests.

@serhii73
serhii73 merged commit 47ff746 into scrapinghub:master Oct 20, 2026
19 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.

Add support for other words ("decade", "fortnight", "century"...)

3 participants