コード例 #1
0
ファイル: date.py プロジェクト: weeksjm/gnumed
 def increment_day(self, date):
     year, month, day = date
     time = GregorianDateTime.from_ymd(year, month, day).to_time()
     if time < GregorianTimeType().get_max_time(
     ) - GregorianDelta.from_days(1):
         return GregorianDateTime.from_time(
             time + GregorianDelta.from_days(1)).to_date_tuple()
     return date
コード例 #2
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
def fit_week_fn(main_frame, current_period, navigation_fn):
    mean = GregorianDateTime.from_time(current_period.mean_time())
    start = GregorianDateTime.from_ymd(mean.year, mean.month, mean.day).to_time()
    weekday = GregorianTimeType().get_day_of_week(start)
    start = start - GregorianDelta.from_days(weekday)
    if not main_frame.week_starts_on_monday():
        start = start - GregorianDelta.from_days(1)
    end = start + GregorianDelta.from_days(7)
    navigation_fn(lambda tp: tp.update(start, end))
コード例 #3
0
ファイル: timetype.py プロジェクト: weeksjm/gnumed
def fit_week_fn(main_frame, current_period, navigation_fn):
    mean = GregorianDateTime.from_time(current_period.mean_time())
    start = GregorianDateTime.from_ymd(mean.year, mean.month, mean.day).to_time()
    weekday = GregorianTimeType().get_day_of_week(start)
    start = start - GregorianDelta.from_days(weekday)
    if not main_frame.week_starts_on_monday():
        start = start - GregorianDelta.from_days(1)
    end = start + GregorianDelta.from_days(7)
    navigation_fn(lambda tp: tp.update(start, end))
コード例 #4
0
 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 - GregorianDelta.from_days(1)
         range_string = self._time_range_string(first_weekday, last_weekday)
         if self.appearance.get_week_start() == "monday":
             return (_("Week") + " %s (%s)") % (GregorianDateTime.from_time(
                 time).week_number, range_string)
         else:
             # It is sunday (don't know what to do about week numbers here)
             return range_string
     # This strip should never be used as minor
     return ""
コード例 #5
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
 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 - GregorianDelta.from_days(1)
         range_string = self._time_range_string(first_weekday, last_weekday)
         if self.appearance.get_week_start() == "monday":
             return (_("Week") + " %s (%s)") % (
                 GregorianDateTime.from_time(time).week_number,
                 range_string
             )
         else:
             # It is sunday (don't know what to do about week numbers here)
             return range_string
     # This strip should never be used as minor
     return ""
コード例 #6
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
def navigate_month_step(current_period, navigation_fn, direction):
    """
    Currently does notice leap years.
    """
    # TODO: NEW-TIME: (year, month, day, hour, minute, second) -> int (days in # month)
    tm = current_period.mean_time()
    gt = GregorianDateTime.from_time(tm)
    if direction > 0:
        if gt.month == 2:
            d = 28
        elif gt.month in (4, 6, 9, 11):
            d = 30
        else:
            d = 31
    else:
        if gt.month == 3:
            d = 28
        elif gt.month in (5, 7, 10, 12):
            d = 30
        else:
            d = 31
    mv = GregorianDelta.from_days(d)
    navigation_fn(lambda tp: tp.move_delta(direction * mv))
コード例 #7
0
def navigate_month_step(current_period, navigation_fn, direction):
    """
    Currently does notice leap years.
    """
    # TODO: NEW-TIME: (year, month, day, hour, minute, second) -> int (days in # month)
    tm = current_period.mean_time()
    gt = GregorianDateTime.from_time(tm)
    if direction > 0:
        if gt.month == 2:
            d = 28
        elif gt.month in (4, 6, 9, 11):
            d = 30
        else:
            d = 31
    else:
        if gt.month == 3:
            d = 28
        elif gt.month in (5, 7, 10, 12):
            d = 30
        else:
            d = 31
    mv = GregorianDelta.from_days(d)
    navigation_fn(lambda tp: tp.move_delta(direction * mv))
コード例 #8
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
def backward_one_week_fn(main_frame, current_period, navigation_fn):
    wk = GregorianDelta.from_days(7)
    navigation_fn(lambda tp: tp.move_delta(-1 * wk))
コード例 #9
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
 def get_default_time_period(self):
     return time_period_center(self.now(), GregorianDelta.from_days(30))
コード例 #10
0
def move_period_num_weeks(period, num):
    delta = GregorianDelta.from_days(7) * num
    start_time = period.start_time + delta
    end_time = period.end_time + delta
    return TimePeriod(start_time, end_time)
コード例 #11
0
 def increment(self, time):
     return time + GregorianDelta.from_days(1)
コード例 #12
0
    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(GregorianDelta.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
コード例 #13
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
 def increment(self, time):
     return time + GregorianDelta.from_days(
         GregorianDateTime.from_time(time).days_in_month()
     )
コード例 #14
0
ファイル: date.py プロジェクト: ncqgm/gnumed
 def increment_day(self, date):
     year, month, day = date
     time = GregorianDateTime.from_ymd(year, month, day).to_time()
     if time < GregorianTimeType().get_max_time() - GregorianDelta.from_days(1):
         return GregorianDateTime.from_time(time + GregorianDelta.from_days(1)).to_date_tuple()
     return date
コード例 #15
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
 def increment(self, time):
     return time + GregorianDelta.from_days(1)
コード例 #16
0
def backward_one_week_fn(main_frame, current_period, navigation_fn):
    wk = GregorianDelta.from_days(7)
    navigation_fn(lambda tp: tp.move_delta(-1 * wk))
コード例 #17
0
 def get_default_time_period(self):
     return time_period_center(self.now(), GregorianDelta.from_days(30))
コード例 #18
0
 def monday_week_1(year):
     from timelinelib.calendar.gregorian.timetype import GregorianTimeType
     jan_4 = GregorianDateTime.from_ymd(year, 1, 4).to_time()
     jan_4_day_of_week = GregorianTimeType().get_day_of_week(jan_4)
     return jan_4 - GregorianDelta.from_days(jan_4_day_of_week)
コード例 #19
0
ファイル: tutorial.py プロジェクト: ncqgm/gnumed
 def get_delta(self, value):
     return GregorianDelta.from_days(value)
コード例 #20
0
ファイル: gregorian.py プロジェクト: ncqgm/gnumed
 def monday_week_1(year):
     from timelinelib.calendar.gregorian.timetype import GregorianTimeType
     jan_4 = GregorianDateTime.from_ymd(year, 1, 4).to_time()
     jan_4_day_of_week = GregorianTimeType().get_day_of_week(jan_4)
     return jan_4 - GregorianDelta.from_days(jan_4_day_of_week)
コード例 #21
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
def backward_one_year_fn(main_frame, current_period, navigation_fn):
    yr = GregorianDelta.from_days(365)
    navigation_fn(lambda tp: tp.move_delta(-1 * yr))
コード例 #22
0
ファイル: utils.py プロジェクト: ncqgm/gnumed
        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(GregorianDelta.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())),
]
コード例 #23
0
 def increment(self, time):
     return time + GregorianDelta.from_days(
         GregorianDateTime.from_time(time).days_in_month())
コード例 #24
0
ファイル: utils.py プロジェクト: luzpaz/gnumed
        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(GregorianDelta.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())),
]
コード例 #25
0
ファイル: tutorial.py プロジェクト: weeksjm/gnumed
 def get_delta(self, value):
     return GregorianDelta.from_days(value)
コード例 #26
0
ファイル: timetype.py プロジェクト: ncqgm/gnumed
def move_period_num_weeks(period, num):
    delta = GregorianDelta.from_days(7) * num
    start_time = period.start_time + delta
    end_time = period.end_time + delta
    return TimePeriod(start_time, end_time)
コード例 #27
0
def backward_one_year_fn(main_frame, current_period, navigation_fn):
    yr = GregorianDelta.from_days(365)
    navigation_fn(lambda tp: tp.move_delta(-1 * yr))