Accept ISO 8601 string, in addition to datetime/date/time object
まだ誰も着手していません。
評価
調査の方向性
まず、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
- スター
- 757
- フォーク
- 148
- 平均マージ
- 6日 1時間
- マージ済み PR(30日)
- 12
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-humanize/humanize のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python-humanize/humanize#379 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
python-humanize/humanize#366 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
python-humanize/humanize#356 · コメント 2 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
python-humanize/humanize#277 · コメント 1 件 ·
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
python-humanize/humanize#270 · コメント 6 件 ·
python-humanize/humanize の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main オープンarea: ci bug perceived difficulty: 3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ClickHouse/clickhouse-connect#1057 ·