fixed hrtime/humantime bug

This commit is contained in:
Niru Maheswaranathan
2015-10-02 18:30:33 -07:00
parent 695eba1fa1
commit 0adb0d8a2d

View File

@@ -14,7 +14,7 @@ except ImportError:
# exports # exports
__all__ = ['table', 'row', 'header', 'hr', 'humantime', 'frame'] __all__ = ['table', 'row', 'header', 'hr', 'humantime', 'frame']
__version__ = '0.1.6' __version__ = '0.1.7'
def table(data, headers, format_spec='5g', column_width=10, outer_char='|', corner_char='+', line_char='-'): def table(data, headers, format_spec='5g', column_width=10, outer_char='|', corner_char='+', line_char='-'):
@@ -212,22 +212,22 @@ def humantime(t):
# weeks # weeks
if t >= 7*60*60*24: if t >= 7*60*60*24:
weeks = np.floor(t / (7.*60.*60.*24.)) weeks = np.floor(t / (7.*60.*60.*24.))
timestr = "{:g} weeks, ".format(weeks) + hrtime(t % (7*60*60*24)) timestr = "{:g} weeks, ".format(weeks) + humantime(t % (7*60*60*24))
# days # days
elif t >= 60*60*24: elif t >= 60*60*24:
days = np.floor(t / (60.*60.*24.)) days = np.floor(t / (60.*60.*24.))
timestr = "{:g} days, ".format(days) + hrtime(t % (60*60*24)) timestr = "{:g} days, ".format(days) + humantime(t % (60*60*24))
# hours # hours
elif t >= 60*60: elif t >= 60*60:
hours = np.floor(t / (60.*60.)) hours = np.floor(t / (60.*60.))
timestr = "{:g} hours, ".format(hours) + hrtime(t % (60*60)) timestr = "{:g} hours, ".format(hours) + humantime(t % (60*60))
# minutes # minutes
elif t >= 60: elif t >= 60:
minutes = np.floor(t / 60.) minutes = np.floor(t / 60.)
timestr = "{:g} min., ".format(minutes) + hrtime(t % 60) timestr = "{:g} min., ".format(minutes) + humantime(t % 60)
# seconds # seconds
elif (t >= 1) | (t == 0): elif (t >= 1) | (t == 0):