Accept ISO 8601 string, in addition to datetime/date/time object
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
Direzione di ricerca
Inizia individuando le funzioni pubbliche di humanize che accettano valori datetime, date o time, inclusa humanize_naturaldate, e verifica la gestione attuale degli input. Controlla come i test esistenti coprono questi punti di ingresso. Il lavoro è completato quando le stringhe ISO 8601 supportate vengono accettate in modo coerente, mentre gli input costituiti da oggetti esistenti e i valori non validi mantengono il comportamento definito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 757
- Fork
- 148
- Merge medio
- 6g 1h
- PR unite (30g)
- 12
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-humanize/humanize
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
python-humanize/humanize#379 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
python-humanize/humanize#366 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
python-humanize/humanize#356 · 2 commenti ·
-
Percentages and ratios Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
python-humanize/humanize#277 · 1 commento ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
python-humanize/humanize#270 · 6 commenti ·
Tutte le issue di python-humanize/humanize
Issue simili
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
simonw/sqlite-utils#872 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100