Skip to content

feat(time): add optional weekday parameter to naturalday (#102) - #377

Open
harmehak0173 wants to merge 2 commits into
python-humanize:mainfrom
harmehak0173:feature/issue-102-naturalday-weekday
Open

feat(time): add optional weekday parameter to naturalday (#102)#377
harmehak0173 wants to merge 2 commits into
python-humanize:mainfrom
harmehak0173:feature/issue-102-naturalday-weekday

Conversation

@harmehak0173

Copy link
Copy Markdown

Summary of Changes

Adds an optional weekday: bool = False parameter to naturalday() to format dates within a 6-day window using weekday names (e.g. "this Saturday", "last Sunday") (#102).

Changes Implemented

  1. Updated naturalday(value, format="%b %d", *, weekday=False) in src/humanize/time.py:
    • Dates 2–6 days in the future return _("this %s") % day_name (e.g. "this Saturday").
    • Dates 2–6 days in the past return _("last %s") % day_name (e.g. "last Sunday").
    • today, tomorrow, and yesterday remain unchanged.
  2. Added comprehensive unit test test_naturalday_weekday in tests/test_time.py.

Testing

  • pytest tests/test_time.py: All 384 tests 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.

1 participant