596
596
return time.strftime('%Y%m%d%H%M%S', time.gmtime(when))
599
def format_delta(delta):
600
"""Get a nice looking string for a time delta.
602
:param delta: The time difference in seconds, can be positive or negative.
603
positive indicates time in the past, negative indicates time in the
604
future. (usually time.time() - stored_time)
605
:return: String formatted to show approximate resolution
611
direction = 'in the future'
615
if seconds < 90: # print seconds up to 90 seconds
617
return '%d second %s' % (seconds, direction,)
619
return '%d seconds %s' % (seconds, direction)
621
minutes = int(seconds / 60)
622
seconds -= 60 * minutes
627
if minutes < 90: # print minutes, seconds up to 90 minutes
629
return '%d minute, %d second%s %s' % (
630
minutes, seconds, plural_seconds, direction)
632
return '%d minutes, %d second%s %s' % (
633
minutes, seconds, plural_seconds, direction)
635
hours = int(minutes / 60)
636
minutes -= 60 * hours
643
return '%d hour, %d minute%s %s' % (hours, minutes,
644
plural_minutes, direction)
645
return '%d hours, %d minute%s %s' % (hours, minutes,
646
plural_minutes, direction)
601
649
"""Return size of given open file."""