From c39a6086a83c2547534d943e3611c4ce0524fafa Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 31 Dec 2019 19:47:32 +0100 Subject: highlight non-workdays --- worktime.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'worktime.py') 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): running_entry = None now = datetime.now(tzlocal()) time_pulled_forward = timedelta() + is_workday = False def __init__(self, start_datetime=None, end_datetime=None, now=None): if now: @@ -140,6 +141,8 @@ class Worktime(object): if day.isoweekday() in workdays and not day in holidays: days_to_work.add(day) + self.is_workday = self.now.date() in days_to_work + self.time_to_work = timedelta(hours = len([day for day in days_to_work if day <= end_date.date()]) * hours_per_day) for day in list(pull_forward): 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(): print(f"{indicator} {difference_string}") else: difference_string = difference_string(total_minutes_difference * timedelta(minutes = 1)) - print(difference_string) + if worktime.is_workday: + print(difference_string) + else: + print(f"({difference_string})") if __name__ == "__main__": sys.exit(main()) -- cgit v1.2.3