Accept ISO 8601 string, in addition to datetime/date/time object
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start by locating the public humanize functions that accept datetime, date, or time values, including humanize_naturaldate, and review their current input handling. Check how existing tests cover these entry points. Done means supported ISO 8601 strings are accepted consistently while existing object inputs and invalid values retain defined behavior.
Written by the indexing model from the issue text.
Description
Motivation:
I believe that the humanize functions are often used indrectly from template engines. In my case I use Jinja2 templating engine and the jinja2_humanize_extension, which relies on the humanize package.
{{ value | humanize_naturaldate }}
In many cases the underlying data (either a database, json-file or csv-file) stores/returns the datetime (or date or time) as a string, formatted in ISO8601 format. But in order to make humanize_naturaldate accept this, I need to first parse it.
{{ value | fromisoformat | humanize_naturaldate }}
The fromisoformat then needs to be set as a filter in the local or global jinja environment.
It would be great if humanize accepted these ISO8661 strings itself.
How to implement:
As far as I can tell, it would be very simple to implement and very simple to maintain. Every function callable by the client, that takes a datetime should start with:
if type(value) == str:
try:
value = datetime.datetime.fromisoformat(value)
else:
value = str
Similarly for date and time objects.
I will admit that I have only studied the code cursorily, and I might have missed some reasons why this is more complex than I currently believe it is.
- Dominant language
- Python
- Stars
- 757
- Forks
- 148
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-humanize/humanize
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
python-humanize/humanize#379 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
python-humanize/humanize#366 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
python-humanize/humanize#356 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
python-humanize/humanize#277 · 1 comment ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
python-humanize/humanize#270 · 6 comments ·
All issues in python-humanize/humanize
Similar issues
-
triage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100