Accept ISO 8601 string, in addition to datetime/date/time object
維護者通常 2 天內回覆
評估
研究方向
首先找出接受 datetime、date 或 time 值的公開 humanize 函式,包括 humanize_naturaldate,並檢視它們目前的輸入處理方式。檢查現有測試如何涵蓋這些進入點。完成的標準是:受支援的 ISO 8601 字串能一致地被接受,同時現有的物件輸入和無效值保留已定義的行為。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Python
- 星號
- 760
- 分支
- 166
- 平均合併
- 4 天 3 小時
- 30 天內合併 PR
- 7
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-humanize/humanize 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
python-humanize/humanize#438 ·
維護者通常 2 天內回覆
-
intcomma returns scientific notation for large floats可能已有人在做 @TheNetherWatcher 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
python-humanize/humanize#431 ·
維護者通常 2 天內回覆
-
docs: document how to run the test suite locally可能已有人在做 @yuefdev 於 3 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
python-humanize/humanize#430 ·
維護者通常 2 天內回覆
-
metric() adds a digit when a value rounds into quetta可能已有人在做 @SashaMIT 於 4 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
python-humanize/humanize#423 ·
維護者通常 2 天內回覆
-
precisedelta() silently drops the sign of negative timedeltas可能已有人在做 @Mukller 於 42 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
python-humanize/humanize#379 ·
維護者通常 2 天內回覆
查看 python-humanize/humanize 的全部 Issue
相似的 Issue
-
needs-human needs-triage
難度 2/5 1-3 小時 新手友好度 76/100
gke-labs/kube-agents#2400 · 1 則留言 ·
維護者通常 1 天內回覆
-
Device Details tables: FS/SF columns contradict each other (nfet_01v8 Vt row, pfet_01v8 Idsat row)未關閉
難度 2/5 1-3 小時 新手友好度 75/100
google/skywater-pdk#450 ·
-
Drained trajectory arrays are overwritten when the sequence buffer is reused可能已有人在做 @sylvesterkaczmarek 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
google-deepmind/bsuite#56 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
LearningCircuit/local-deep-research#7206 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
chingu-voyages/V62-tier3-team-33#285 ·
維護者通常 1 天內回覆