Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def express_as_duration(delta)
- timestamp = []
- hours = int(delta / (60 * 60))
- minutes = int((delta % (60 * 60)) / 60)
- seconds = delta % 60
- if hours > 0:
- if hours == 1:
- timestamp.append("1 hour")
- else:
- timestamp.append("{} hours".format(hours))
- if minutes > 0:
- if minutes == 1:
- timestamp.append("1 minute")
- else:
- timestamp.append("{} minutes".format(minutes))
- timestamp.append("{0:.2f} seconds".format(seconds))
- return ', '.join(timestamp)
Add Comment
Please, Sign In to add comment