arrow

Utilities

人間に優しいデート

概要 arrow

Arrow は、日付と時刻の作成、操作、書式設定、変換に対する人間に優しいアプローチを提供する Python ライブラリです。シンプルな API、デフォルトでタイムゾーン対応、.shift(days=-1) や .humanize() などの直感的な時間シフト メソッドを備えた datetime のドロップイン代替として機能します。

PyRunでは、マイクロピップ経由で Arrow を利用できます。日付の算術計算、タイムゾーンの変換、相対時間の書式設定、および日付の解析を、Python の標準日時定型文を読み進めることなく、すべてブラウザー内で行うことができ、セットアップは必要ありません。

コードと実行の出力

人間に優しいタイムゾーン変換とタイムシフト。

Arrow Date & Timeエディターで実行
import arrow

now = arrow.now()
print("Now (local):", now.format("YYYY-MM-DD HH:mm:ss ZZ"))
print("Now (UTC)  :", now.to("UTC").format("YYYY-MM-DD HH:mm:ss"))

past = now.shift(days=-10, hours=-3)
print("\n10 days 3 hrs ago:", past.humanize())

dt = arrow.get("2025-07-04 12:00:00", "YYYY-MM-DD HH:mm:ss", tzinfo="US/Eastern")
print("\nNew York :", dt.format("YYYY-MM-DD HH:mm ZZ"))
print("Tokyo    :", dt.to("Asia/Tokyo").format("YYYY-MM-DD HH:mm ZZ"))
print("Mumbai   :", dt.to("Asia/Kolkata").format("YYYY-MM-DD HH:mm ZZ"))

関連パッケージ

推奨される Python リソース

関連するインタラクティブなチュートリアル、チートシート、コード比較で知識を深めてください。