def increment_day(self, date): year, month, day = date time = PharaonicDateTime.from_ymd(year, month, day).to_time() if time < PharaonicTimeType().get_max_time( ) - PharaonicDelta.from_days(1): return PharaonicDateTime.from_time( time + PharaonicDelta.from_days(1)).to_date_tuple() return date
def fit_week_fn(main_frame, current_period, navigation_fn): mean = PharaonicDateTime.from_time(current_period.mean_time()) start = PharaonicDateTime.from_ymd(mean.year, mean.month, mean.day).to_time() weekday = PharaonicTimeType().get_day_of_week(start) start = start - PharaonicDelta.from_days(weekday) if not main_frame.week_starts_on_monday(): start = start - PharaonicDelta.from_days(1) end = start + PharaonicDelta.from_days(10) navigation_fn(lambda tp: tp.update(start, end))
def navigate_month_step(current_period, navigation_fn, direction): # TODO: NEW-TIME: (year, month, day, hour, minute, second) -> int (days in # month) tm = current_period.mean_time() pt = PharaonicDateTime.from_time(tm) if pt.month == 13: d = 5 d = 30 mv = PharaonicDelta.from_days(d) navigation_fn(lambda tp: tp.move_delta(direction * mv))
def label(self, time, major=False): if major: first_weekday = self.start(time) next_first_weekday = self.increment(first_weekday) last_weekday = next_first_weekday - PharaonicDelta.from_days(1) range_string = self._time_range_string(first_weekday, last_weekday) if self.appearance.get_week_start() == "tkyriaka": return (_("Week") + " %s (%s)") % (PharaonicDateTime.from_time( time).week_number, range_string) else: # It is Psabbaton (don't know what to do about week numbers here) return range_string # This strip should never be used as minor return ""
def move_period_num_weeks(period, num): delta = PharaonicDelta.from_days(7) * num start_time = period.start_time + delta end_time = period.end_time + delta return TimePeriod(start_time, end_time)
def increment(self, time): return time + PharaonicDelta.from_days(1)
def increment(self, time): return time + PharaonicDelta.from_days( PharaonicDateTime.from_time(time).days_in_month() )
def backward_one_year_fn(main_frame, current_period, navigation_fn): yr = PharaonicDelta.from_days(365) navigation_fn(lambda tp: tp.move_delta(-1 * yr))
def backward_one_week_fn(main_frame, current_period, navigation_fn): wk = PharaonicDelta.from_days(7) navigation_fn(lambda tp: tp.move_delta(-1 * wk))
def get_default_time_period(self): return time_period_center(self.now(), PharaonicDelta.from_days(30))
event.set_locked(True) else: event.set_ends_today(not event.get_ends_today()) return event EVENT_MODIFIERS = [ ("change fuzzy", lambda event: event.set_fuzzy(not event.get_fuzzy())), ("change locked", lambda event: event.set_locked(not event.get_locked())), ("change ends today", modifier_change_ends_today), ("change id", lambda event: event.set_id(inc(event.get_id()))), ("change time period", lambda event: event.set_time_period(event.get_time_period().move_delta(PharaonicDelta.from_days(1)))), ("change text", lambda event: event.set_text("was: %s" % event.get_text())), ("change category", lambda event: event.set_category(new_cat(event))), ("change icon", lambda event: event.set_icon("was: %s" % event.get_icon())), ("change description", lambda event: event.set_description("was: %s" % event.get_description())), ("change hyperlink", lambda event: event.set_hyperlink("was: %s" % event.get_hyperlink())), ("change progress", lambda event: event.set_progress(new_progress(event))), ("change alert", lambda event: event.set_alert("was: %s" % event.get_alert())), ]