Minor optimization in ftime

This commit is contained in:
Andrew Resch 2008-11-29 05:48:11 +00:00
parent 95bf260518
commit cb77d16812
1 changed files with 4 additions and 4 deletions

View File

@ -298,20 +298,20 @@ def ftime(seconds):
if seconds < 60: if seconds < 60:
return '%ds' % (seconds) return '%ds' % (seconds)
minutes = seconds / 60 minutes = seconds / 60
seconds = seconds % 60
if minutes < 60: if minutes < 60:
seconds = seconds % 60
return '%dm %ds' % (minutes, seconds) return '%dm %ds' % (minutes, seconds)
hours = minutes / 60 hours = minutes / 60
minutes = minutes % 60
if hours < 24: if hours < 24:
minutes = minutes % 60
return '%dh %dm' % (hours, minutes) return '%dh %dm' % (hours, minutes)
days = hours / 24 days = hours / 24
hours = hours % 24
if days < 7: if days < 7:
hours = hours % 24
return '%dd %dh' % (days, hours) return '%dd %dh' % (days, hours)
weeks = days / 7 weeks = days / 7
days = days % 7
if weeks < 52: if weeks < 52:
days = days % 7
return '%dw %dd' % (weeks, days) return '%dw %dd' % (weeks, days)
years = weeks / 52 years = weeks / 52
weeks = weeks % 52 weeks = weeks % 52