5 from datetime import datetime
10 def timestamp() -> str:
11 t = datetime.fromtimestamp(time.time())
12 return t.strftime("%d/%b/%Y:%H:%M:%S%Z")
15 def describe_age_of_file(filename) -> str:
18 ts = os.stat(filename).st_ctime
20 return describe_duration(age)
21 except Exception as e:
25 def describe_age_of_file_briefly(filename) -> str:
28 ts = os.stat(filename).st_ctime
30 return describe_duration_briefly(age)
31 except Exception as e:
35 def describe_duration(age: int) -> str:
36 days = divmod(age, constants.seconds_per_day)
37 hours = divmod(days[1], constants.seconds_per_hour)
38 minutes = divmod(hours[1], constants.seconds_per_minute)
42 descr = f"{int(days[0]):d} days, "
46 descr = descr + f"{int(hours[0]):d} hours, "
48 descr = descr + "1 hour, "
50 descr = descr + "and "
52 descr = descr + "1 minute"
54 descr = descr + f"{int(minutes[0]):d} minutes"
58 def describe_duration_briefly(age: int) -> str:
59 days = divmod(age, constants.seconds_per_day)
60 hours = divmod(days[1], constants.seconds_per_hour)
61 minutes = divmod(hours[1], constants.seconds_per_minute)
65 descr = f"{int(days[0]):d}d "
67 descr = descr + f"{int(hours[0]):d}h "
68 descr = descr + f"{int(minutes[0]):d}m"
72 # x = describe_age_of_file_briefly("pages/clock_10_none.html")