This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/util/timeformat.py

17 lines
602 B
Python
Raw Normal View History

2013-08-24 10:45:05 +02:00
def timeformat(seconds):
if seconds < 60:
timestamp = str(seconds) + "s"
elif seconds >= 60 and seconds < 3600:
timestamp = "%s:%s" % (seconds/60, seconds%60)
elif seconds >= 3600 and seconds < 86400:
hours = seconds / 3600
seconds = 3600*hours
timestamp = "%s:%s:%s" % (hours, seconds/60, seconds%60)
elif seconds >= 86400:
days = seconds / 86400
seconds = 86400*days
hours = seconds / 3600
seconds = 3600*hours
timestamp = "%s days, %s:%s:%s" % (days, hours, seconds/60, seconds%60)
return timestamp