summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xprogress.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/progress.py b/progress.py
index 47ee5d9..6eb48c8 100755
--- a/progress.py
+++ b/progress.py
@@ -3,9 +3,10 @@
from datetime import datetime, timedelta
from calendar import *
+
class Progress(object):
- """Displays the time left in the day/week/month/year as a percentage. Inspired
- by https://twitter.com/year_progress
+ """Displays the time left in the day/workweek/month/year as a
+ percentage. Inspired by https://twitter.com/year_progress
"""
@@ -16,16 +17,17 @@ class Progress(object):
month_max = max(list(cal.itermonthdays(self.now.year, self.now.month)))
year_max = 366 if isleap(self.now.year) else 365
self.dura = {
- 'day': timedelta(hours=8),
- 'week': timedelta(days=7),
- 'month': timedelta(days=month_max),
- 'year': timedelta(days=year_max),
+ "day": timedelta(hours=8),
+ "week": timedelta(days=7),
+ "month": timedelta(days=month_max),
+ "year": timedelta(days=year_max),
}
self.end = {
- 'year': datetime(self.now.year+1, 1, 1),
- 'day': datetime(self.now.year, self.now.month, self.now.day, hour=16),
- 'week': datetime(self.now.year, self.now.month, self.now.day) + weekdays_left,
- 'month': datetime(self.now.year, self.now.month, month_max),
+ "year": datetime(self.now.year + 1, 1, 1),
+ "day": datetime(self.now.year, self.now.month, self.now.day, hour=16),
+ "week": datetime(self.now.year, self.now.month, self.now.day)
+ + weekdays_left,
+ "month": datetime(self.now.year, self.now.month, month_max),
}
def calc(self, key):
@@ -33,11 +35,12 @@ class Progress(object):
def __str__(self):
return "d: {d:.1%} | w: {w:.1%} | m: {m:.1%} | y: {y:.1%}".format(
- d=self.calc('day'),
- w=self.calc('week'),
- m=self.calc('month'),
- y=self.calc('year'),
+ d=self.calc("day"),
+ w=self.calc("week"),
+ m=self.calc("month"),
+ y=self.calc("year"),
)
-if __name__ == '__main__':
+
+if __name__ == "__main__":
print(str(Progress()))