1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

日付→西暦0年からの総日数や総時間数への変換

Last updated at Posted at 2018-10-10

検索しても出てこなかったので.
あまりスマートじゃないです.
カレンダーの定義をうまく使えばできそうですが...

datetime2total_hours.py
import datetime

t  = datetime.datetime(2000,1,1,0,0) # 対象とする日付
t0 = datetime.datetime(   1,1,1,0,0) # 定義可能な一番古い日付
dt = datetime.timedelta(days=366) # 西暦0年が存在したとしたらの日数

total_days  = (t-t0 + dt).days
total_hours = total_days*24
1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?