Skip to content

Instantly share code, notes, and snippets.

@naoyat
Created November 8, 2015 07:57
Show Gist options
  • Save naoyat/ad469e86a8ff3c1874ad to your computer and use it in GitHub Desktop.
Save naoyat/ad469e86a8ff3c1874ad to your computer and use it in GitHub Desktop.
Click: support longer eta (>1day)
diff -ru click-5.1/click/_termui_impl.py click-5.1-naoyat/click/_termui_impl.py
--- click-5.1/click/_termui_impl.py 2015-08-17 20:16:32.000000000 +0900
+++ click-5.1-naoyat/click/_termui_impl.py 2015-11-08 16:54:04.000000000 +0900
@@ -128,7 +128,18 @@
def format_eta(self):
if self.eta_known:
- return time.strftime('%H:%M:%S', time.gmtime(self.eta + 1))
+ t = self.eta
+ seconds = t % 60
+ t /= 60
+ minutes = t % 60
+ t /= 60
+ hours = t % 24
+ t /= 24
+ if t > 0:
+ days = t
+ return '%dd %02d:%02d:%02d' % (days, hours, minutes, seconds)
+ else:
+ return '%02d:%02d:%02d' % (hours, minutes, seconds)
return ''
def format_pos(self):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment