This code prints a false warning once per year, in the night of the clock shift (central European summer time to central European time):
import os
import datetime
now = datetime.datetime.now()
age = now - datetime.datetime.fromtimestamp(os.path.getmtime(file_name))
if (age.seconds + age.days * 24 * 3600) < -180:
print('WARN: file has timestap from future?: %s' % age)
How to make this code work even during this yearly one hour clock shift?
from getmtime() vs datetime.now():
No comments:
Post a Comment