diff options
Diffstat (limited to 'worktime.py')
-rwxr-xr-x | worktime.py | 8 |
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 | ||
198 | if __name__ == "__main__": | 204 | if __name__ == "__main__": |
199 | sys.exit(main()) | 205 | sys.exit(main()) |