##// END OF EJS Templates
progress: handle days, weeks and years...
timeless -
r13236:3f299f5d default
parent child Browse files
Show More
@@ -69,8 +69,29 b' def fmtremaining(seconds):'
69 minutes += 1
69 minutes += 1
70 hours = minutes // 60
70 hours = minutes // 60
71 minutes -= hours * 60
71 minutes -= hours * 60
72 # i18n: format X hours and YY minutes as "XhYYm"
72 if hours < 30:
73 return _("%dh%02dm") % (hours, minutes)
73 # i18n: format X hours and YY minutes as "XhYYm"
74 return _("%dh%02dm") % (hours, minutes)
75 # we're going to ignore minutes in this case
76 hours += 1
77 days = hours // 24
78 hours -= days * 24
79 if days < 15:
80 # i18n: format X days and YY hours as "XdYYh"
81 return _("%dd%02dh") % (days, hours)
82 # we're going to ignore hours in this case
83 days += 1
84 weeks = days // 7
85 days -= weeks * 7
86 if weeks < 55:
87 # i18n: format X weeks and YY days as "XwYYd"
88 return _("%dw%02dd") % (weeks, days)
89 # we're going to ignore days and treat a year as 52 weeks
90 weeks += 1
91 years = weeks // 52
92 weeks -= years * 52
93 # i18n: format X years and YY weeks as "XyYYw"
94 return _("%dy%02dw") % (years, weeks)
74
95
75 class progbar(object):
96 class progbar(object):
76 def __init__(self, ui):
97 def __init__(self, ui):
@@ -141,6 +141,23 b' test delay time estimates'
141 loop [==============================> ] 3/4 2h47m
141 loop [==============================> ] 3/4 2h47m
142 \r (esc)
142 \r (esc)
143
143
144 $ MOCKTIME=1000000 hg -y loop 4 2>&1 | python $TESTDIR/filtercr.py
145
146 loop [ ] 0/4
147 loop [=========> ] 1/4 5w00d
148 loop [====================> ] 2/4 3w03d
149 loop [=============================> ] 3/4 11d14h
150 \r (esc)
151
152
153 $ MOCKTIME=14000000 hg -y loop 4 2>&1 | python $TESTDIR/filtercr.py
154
155 loop [ ] 0/4
156 loop [=========> ] 1/4 1y18w
157 loop [===================> ] 2/4 46w03d
158 loop [=============================> ] 3/4 23w02d
159 \r (esc)
160
144 Time estimates should not fail when there's no end point:
161 Time estimates should not fail when there's no end point:
145 $ hg -y loop -- -4 2>&1 | python $TESTDIR/filtercr.py
162 $ hg -y loop -- -4 2>&1 | python $TESTDIR/filtercr.py
146
163
General Comments 0
You need to be logged in to leave comments. Login now