summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2019-12-31 19:47:32 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2019-12-31 19:47:32 +0100
commitc39a6086a83c2547534d943e3611c4ce0524fafa (patch)
treedebdfd3a907d2379e1b4076e4787911f242e6bf1
parent33b4e0eb74fee27d8edacb581fd6eeb10cce9f4f (diff)
downloadutils-c39a6086a83c2547534d943e3611c4ce0524fafa.tar
utils-c39a6086a83c2547534d943e3611c4ce0524fafa.tar.gz
utils-c39a6086a83c2547534d943e3611c4ce0524fafa.tar.bz2
utils-c39a6086a83c2547534d943e3611c4ce0524fafa.tar.xz
utils-c39a6086a83c2547534d943e3611c4ce0524fafa.zip
highlight non-workdays
-rwxr-xr-xworktime.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/worktime.py b/worktime.py
index 36436ae..9c72d30 100755
--- a/worktime.py
+++ b/worktime.py
@@ -65,6 +65,7 @@ class Worktime(object):
65 running_entry = None 65 running_entry = None
66 now = datetime.now(tzlocal()) 66 now = datetime.now(tzlocal())
67 time_pulled_forward = timedelta() 67 time_pulled_forward = timedelta()
68 is_workday = False
68 69
69 def __init__(self, start_datetime=None, end_datetime=None, now=None): 70 def __init__(self, start_datetime=None, end_datetime=None, now=None):
70 if now: 71 if now:
@@ -140,6 +141,8 @@ class Worktime(object):
140 if day.isoweekday() in workdays and not day in holidays: 141 if day.isoweekday() in workdays and not day in holidays:
141 days_to_work.add(day) 142 days_to_work.add(day)
142 143
144 self.is_workday = self.now.date() in days_to_work
145
143 self.time_to_work = timedelta(hours = len([day for day in days_to_work if day <= end_date.date()]) * hours_per_day) 146 self.time_to_work = timedelta(hours = len([day for day in days_to_work if day <= end_date.date()]) * hours_per_day)
144 for day in list(pull_forward): 147 for day in list(pull_forward):
145 days_forward = set([d for d in days_to_work if d >= end_date.date() and d < day and not d in pull_forward]) 148 days_forward = set([d for d in days_to_work if d >= end_date.date() and d < day and not d in pull_forward])
@@ -193,7 +196,10 @@ def main():
193 print(f"{indicator} {difference_string}") 196 print(f"{indicator} {difference_string}")
194 else: 197 else:
195 difference_string = difference_string(total_minutes_difference * timedelta(minutes = 1)) 198 difference_string = difference_string(total_minutes_difference * timedelta(minutes = 1))
196 print(difference_string) 199 if worktime.is_workday:
200 print(difference_string)
201 else:
202 print(f"({difference_string})")
197 203
198if __name__ == "__main__": 204if __name__ == "__main__":
199 sys.exit(main()) 205 sys.exit(main())