597
597
return time.strftime('%Y%m%d%H%M%S', time.gmtime(when))
600
def format_delta(delta):
601
"""Get a nice looking string for a time delta.
603
:param delta: The time difference in seconds, can be positive or negative.
604
positive indicates time in the past, negative indicates time in the
605
future. (usually time.time() - stored_time)
606
:return: String formatted to show approximate resolution
612
direction = 'in the future'
616
if seconds < 90: # print seconds up to 90 seconds
618
return '%d second %s' % (seconds, direction,)
620
return '%d seconds %s' % (seconds, direction)
622
minutes = int(seconds / 60)
623
seconds -= 60 * minutes
628
if minutes < 90: # print minutes, seconds up to 90 minutes
630
return '%d minute, %d second%s %s' % (
631
minutes, seconds, plural_seconds, direction)
633
return '%d minutes, %d second%s %s' % (
634
minutes, seconds, plural_seconds, direction)
636
hours = int(minutes / 60)
637
minutes -= 60 * hours
644
return '%d hour, %d minute%s %s' % (hours, minutes,
645
plural_minutes, direction)
646
return '%d hours, %d minute%s %s' % (hours, minutes,
647
plural_minutes, direction)
602
650
"""Return size of given open file."""
1039
1087
_cached_user_encoding = locale.getpreferredencoding()
1040
1088
except locale.Error, e:
1041
1089
sys.stderr.write('bzr: warning: %s\n'
1042
' Could not what text encoding to use.\n'
1090
' Could not determine what text encoding to use.\n'
1043
1091
' This error usually means your Python interpreter\n'
1044
1092
' doesn\'t support the locale set by $LANG (%s)\n'
1045
1093
" Continuing with ascii encoding.\n"