time difference inflected as before/after
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 127
- PR merge metrics
- No merged PRs in 30d
Description
I'd like to see a feature like the following:
```
>>> p.date_diff(datetime.timedelta(minutes=-30))
'00:30:00 before'
>>> p.date_diff(5)
'00:00:05 after'
>>> p.date_diff(0)
'at'
```
I would expect one to use the result to produce nice output for a time difference like:
> Your flight departed 00:00:05 after its scheduled departure.
It would be nice if it accepted a time formatter such that it could alternately emit:
```
>>> p.date_diff(datetime.timedelta(minutes=-30), fmt=nice_time)
'30 minutes before'
>>> p.date_diff(5, fmt=nice_time)
'five seconds after'
>>> p.date_diff(0, fmt=nice_time)
'at'
```
Perhaps that inflection is too trivial for a library like inflect. Or perhaps there are nuances I haven't yet considered.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue proposes a new p.date_diff entry point with before/after and at outputs, plus an optional fmt callable. No files or tests are named, so begin by inspecting the existing inflect API and test layout; done means the shown positive, negative, zero, and custom-format examples behave as specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100