python-humanize / python-humanize/humanize
Accept ISO 8601 string, in addition to datetime/date/time object
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 756
- フォーク
- 148
- 平均マージ
- 6日 1時間
- マージ済み PR(30日)
- 12
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、datetime、date、または time の値を受け取る公開 humanize 関数(humanize_naturaldate を含む)を特定し、現在の入力処理を確認します。既存のテストでこれらのエントリーポイントがどのようにカバーされているかを確認します。対応する ISO 8601 文字列が一貫して受け入れられ、既存のオブジェクト入力と無効な値については定義された動作が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100