Also added a fuzzy time string to the build doc header to make it easier to see the age of the build

This commit is contained in:
Veronica K. B. Olsen
2020-06-23 20:23:52 +02:00
parent b47d6b6546
commit bc8873fdd4
2 changed files with 49 additions and 7 deletions
+24
View File
@@ -193,3 +193,27 @@ def transferCase(theSource, theTarget):
theResult = theTarget.lower()
return theResult
def fuzzyTime(secDiff):
"""Converts a time difference in seconds into a fuzzy time string.
"""
if secDiff < 0:
return "in the future"
elif secDiff < 15:
return "just now"
elif secDiff < 45:
return "a few seconds ago"
elif secDiff < 90:
return "a minute ago"
elif secDiff < 3300: # 55 minutes
return "%d minutes ago" % int(round(secDiff/60))
elif secDiff < 5400: # 90 minutes
return "an hour ago"
elif secDiff < 84600: # 23.5 hours
return "%d hours ago" % int(round(secDiff/3600))
elif secDiff < 129600: # 1.5 days
return "a day ago"
elif secDiff < 8640000: # 100 days
return "%d days ago" % int(round(secDiff/86400))
else:
return "ages ago"