mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2026-02-04 17:14:42 +01:00
Marietje 4.1: Addition of Django REST framework, Swagger, Dark mode and updates to Django and Bootstrap
This commit is contained in:
13
marietje/stats/services.py
Normal file
13
marietje/stats/services.py
Normal file
@ -0,0 +1,13 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
def age_text(last_updated):
|
||||
current_age = datetime.now() - last_updated
|
||||
minutes = (current_age.seconds % 3600) / 60
|
||||
hours = current_age.seconds / 3600
|
||||
minutestr = "minute" if minutes == 1 else "minutes"
|
||||
hourstr = "hour" if hours == 1 else "hours"
|
||||
if current_age < timedelta(hours=1):
|
||||
return "Stats were updated {:.0f} {} ago.".format(minutes, minutestr)
|
||||
|
||||
return "Stats were updated {:.0f} {} and {:.0f} {} ago.".format(hours, hourstr, minutes, minutestr)
|
||||
Reference in New Issue
Block a user