import constants
from datetime import datetime
+
def timestamp():
t = datetime.fromtimestamp(time.time())
- return t.strftime('%d/%b/%Y:%H:%M:%S%Z')
+ return t.strftime("%d/%b/%Y:%H:%M:%S%Z")
+
def describe_age_of_file(filename):
try:
except Exception as e:
return "?????"
+
def describe_age_of_file_briefly(filename):
try:
now = time.time()
except Exception as e:
return "?????"
+
def describe_duration(age):
days = divmod(age, constants.seconds_per_day)
hours = divmod(days[1], constants.seconds_per_hour)
minutes = divmod(hours[1], constants.seconds_per_minute)
descr = ""
- if (days[0] > 1):
+ if days[0] > 1:
descr = "%d days, " % days[0]
- elif (days[0] == 1):
+ elif days[0] == 1:
descr = "1 day, "
- if (hours[0] > 1):
+ if hours[0] > 1:
descr = descr + ("%d hours, " % hours[0])
- elif (hours[0] == 1):
+ elif hours[0] == 1:
descr = descr + "1 hour, "
- if (len(descr) > 0):
+ if len(descr) > 0:
descr = descr + "and "
- if (minutes[0] == 1):
+ if minutes[0] == 1:
descr = descr + "1 minute"
else:
descr = descr + ("%d minutes" % minutes[0])
return descr
+
def describe_duration_briefly(age):
days = divmod(age, constants.seconds_per_day)
hours = divmod(days[1], constants.seconds_per_hour)
minutes = divmod(hours[1], constants.seconds_per_minute)
descr = ""
- if (days[0] > 0):
+ if days[0] > 0:
descr = "%dd " % days[0]
- if (hours[0] > 0):
+ if hours[0] > 0:
descr = descr + ("%dh " % hours[0])
descr = descr + ("%dm" % minutes[0])
return descr
-#x = describe_age_of_file_briefly("pages/clock_10_none.html")
-#print x
+
+# x = describe_age_of_file_briefly("pages/clock_10_none.html")
+# print x