def increment_day(self, date): year, month, day = date time = CopticDateTime.from_ymd(year, month, day).to_time() if time < CopticTimeType().get_max_time() - CopticDelta.from_days(1): return CopticDateTime.from_time( time + CopticDelta.from_days(1)).to_date_tuple() return date
def fit_week_fn(main_frame, current_period, navigation_fn): mean = CopticDateTime.from_time(current_period.mean_time()) start = CopticDateTime.from_ymd(mean.year, mean.month, mean.day).to_time() weekday = CopticTimeType().get_day_of_week(start) start = start - CopticDelta.from_days(weekday) if not main_frame.week_starts_on_monday(): start = start - CopticDelta.from_days(1) end = start + CopticDelta.from_days(7) navigation_fn(lambda tp: tp.update(start, end))
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 - CopticDelta.from_days(1) range_string = self._time_range_string(first_weekday, last_weekday) if self.appearance.get_week_start() == "tkyriaka": return (_("Week") + " %s (%s)") % ( CopticDateTime.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 navigate_month_step(current_period, navigation_fn, direction): from timelinelib.calendar.coptic.coptic import is_leap_year # TODO: NEW-TIME: (year, month, day, hour, minute, second) -> int (days in # month) tm = current_period.mean_time() gt = CopticDateTime.from_time(tm) if gt.month == 13: if is_leap_year(gt.year): d = 6 d = 5 d = 30 mv = CopticDelta.from_days(d) navigation_fn(lambda tp: tp.move_delta(direction * mv))
def move_period_num_weeks(period, num): delta = CopticDelta.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 + CopticDelta.from_seconds(60)
def increment(self, time): return time + CopticDelta.from_days(1)
def increment(self, time): return time + CopticDelta.from_days( CopticDateTime.from_time(time).days_in_month())
def backward_one_year_fn(main_frame, current_period, navigation_fn): yr = CopticDelta.from_days(365) navigation_fn(lambda tp: tp.move_delta(-1 * yr))
def backward_one_week_fn(main_frame, current_period, navigation_fn): wk = CopticDelta.from_days(7) navigation_fn(lambda tp: tp.move_delta(-1 * wk))
def get_min_zoom_delta(self): return (CopticDelta.from_seconds(60), _("Can't zoom deeper than 1 minute"))
def get_default_time_period(self): return time_period_center(self.now(), CopticDelta.from_days(30))
if event.get_locked(): event.set_locked(False) event.set_ends_today(not event.get_ends_today()) 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(CopticDelta.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())), ] SUBEVENT_MODIFIERS = EVENT_MODIFIERS
def tkyriaka_week_1(year): from timelinelib.calendar.coptic.timetype import CopticTimeType thoth_4 = CopticDateTime.from_ymd(year, 1, 4).to_time() thoth_4_day_of_week = CopticTimeType().get_day_of_week(thoth_4) return thoth_4 - CopticDelta.from_days(thoth_4_day_of_week)