ファイル日付比較ルーチンを作成しようとしています。以下はかなり不格好なアプローチだと思います。
timedelta の属性やメソッド、またはそれらが呼ばれるものに関する情報を見つけるのに苦労しました。したがって、以下の日時の差を日、分、秒でのみ測定しました。年を表すリスト項目はありません。
代替案についての提案は、大歓迎です。
import os
import datetime
from datetime import datetime
import sys
def datetime_filedif(filepath1e, filepath2e):
filelpath1 = str(filepath1e)
filepath1 = str(filepath1e)
filepath2 = str(filepath2e)
filepath1_lmdate = datetime.fromtimestamp(os.path.getmtime(filepath1))
filepath2_lmdate = datetime.fromtimestamp(os.path.getmtime(filepath2))
td_files = filepath2_lmdate - filepath1_lmdate #Time delta of the 2 filedates
td_list = [('td_files.days', td_files.days), ('td_hrs', int(str(td_files.seconds))/3600), ('td_minutes', (int(str(td_files.seconds))%3600)/60), ('td_seconds', (int(str(td_files.seconds))%3600)%60)]
print "Line 25: ", str(td_list)
return td_list