Skip to content

Honor PREFER_DATES_FROM for date_formats with a month but no year - #1399

Open
AdrianAtZyte wants to merge 5 commits into
scrapinghub:masterfrom
AdrianAtZyte:prefer-dates-from-yearless-formats
Open

AdrianAtZyte wants to merge 5 commits into
scrapinghub:masterfrom
AdrianAtZyte:prefer-dates-from-yearless-formats

Conversation

@AdrianAtZyte

Copy link
Copy Markdown
Member

Closes #1350

@codecov

codecov Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.28%. Comparing base (f1c58d6) to head (4fc9efe).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1399      +/-   ##
==========================================
+ Coverage   99.18%   99.28%   +0.10%     
==========================================
  Files         239      239              
  Lines        4030     4060      +30     
==========================================
+ Hits         3997     4031      +34     
+ Misses         33       29       -4     

☔ 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.

@codspeed

codspeed Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks


Comparing AdrianAtZyte:prefer-dates-from-yearless-formats (4fc9efe) with master (f1c58d6)

Open in CodSpeed

@AdrianAtZyte
AdrianAtZyte marked this pull request as ready for review September 23, 2026 07:34

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

Code review (claude code-review, at f26560f). Not approving as is, there is a regression in a common case:

  1. Today is pushed a year ahead. The year shift compares a midnight-truncated date with now, which still has its time of day. With RELATIVE_BASE=2026-06-15 10:00, format %B %d, input June 15 and PREFER_DATES_FROM='future', the result is 2027-06-15; before this PR it was 2026-06-15. The comparison needs date granularity, or an equal date should be exempt.
  2. Month-only formats depend on an arbitrary day. For %B and input June with base 2026-06-15, 'past' gives 2025-06-20 and 'future' gives 2026-06-20, because set_correct_day_from_settings fills in a day first. A month-only input should be compared by month.
  3. Day-only and month-less formats are skipped. %d with input 10, 'future' and base 2026-06-15 still returns 2026-06-10, and %H:%M is also left alone, so the setting behaves differently for %d %B and for %d or %H:%M. test_prefer_dates_from_with_monthless_date_formats only asserts year == 2026, so it locks in "no preference" instead of checking the date.
  4. Behaviour change for existing users. Anyone using PREFER_DATES_FROM with year-less date_formats now gets a different year. That needs a docs or changelog entry, and boundary tests (same day, a later time of day, a leap-year base).

This branch has not been deployed

No deployments
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.

2 participants