- # helpers
-
- def set_visibilities(self):
- for uuid, t in self.tasks.items():
- t.visible = len([tag for tag in self.t_filter_and if not tag in t.tags.now]) == 0\
- and len([tag for tag in self.t_filter_not if tag in t.tags.now]) == 0\
- and ((not self.hide_unchosen) or uuid in self.selected_day.todos.keys())
- for todo in self.todos.values():
- todo.visible = len([tag for tag in self.t_filter_and if not tag in todo.day_tags | todo.task.tags.now ]) == 0\
- and len([tag for tag in self.t_filter_not if tag in todo.day_tags | todo.task.tags.now ]) == 0\
- and ((not self.hide_done) or (not todo.done))
-
- def get_limit_days_from_date_strings(self, start_date_str, end_date_str):
- todays_date_obj = datetime.strptime(today_date(), DATE_FORMAT)
- yesterdays_date_obj = todays_date_obj - timedelta(1)
- def get_day_limit_obj(index, day_limit_string):
- date_obj = datetime.strptime(sorted(self.days.keys())[index], DATE_FORMAT)
- if day_limit_string and len(day_limit_string) > 0:
- if day_limit_string in {'today', 'yesterday'}:
- date_obj = todays_date_obj if day_limit_string == 'today' else yesterdays_date_obj
- else:
- date_obj = datetime.strptime(day_limit_string, DATE_FORMAT)
- return date_obj
- start_date_obj = get_day_limit_obj(0, start_date_str)
- end_date_obj = get_day_limit_obj(-1, end_date_str)
- return start_date_obj, end_date_obj
-
- def neighbor_dates(self):
- current_date = datetime.strptime(self.selected_date, DATE_FORMAT)
- prev_date = current_date - timedelta(days=1)
- prev_date_str = prev_date.strftime(DATE_FORMAT)
- next_date = current_date + timedelta(days=1)
- next_date_str = next_date.strftime(DATE_FORMAT)
- return prev_date_str, next_date_str
-