Exemplo n.º 1
0
def _whole_number_of_months(period):
    """
    >>> from specs.utils import gregorian_period
    >>> from specs.utils import install_gettext_in_builtin_namespace

    >>> _whole_number_of_months(gregorian_period("1 Jan 2013", "1 Jan 2014"))
    True
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_months(gregorian_period("1 Jan 2013", "1 Mar 2014"))
    True
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_months(gregorian_period("2 Jan 2013", "2 Mar 2014"))
    False
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_months(gregorian_period("1 Jan 2013 12:00", "1 Mar 2014"))
    False
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _
    """
    start, end = gregorian.from_time(period.start_time), gregorian.from_time(
        period.end_time)
    start_months = start.year * 12 + start.month
    end_months = end.year * 12 + end.month
    month_diff = end_months - start_months
    return (start.is_first_of_month() and end.is_first_of_month()
            and month_diff > 0)
Exemplo n.º 2
0
def move_period_num_months(period, num):
    try:
        delta = num
        years = abs(delta) / 12
        gregorian_start = gregorian.from_time(period.start_time)
        gregorian_end = gregorian.from_time(period.end_time)
        if num < 0:
            years = -years
        delta = delta - 12 * years
        if delta < 0:
            start_month = gregorian_start.month + 12 + delta
            end_month = gregorian_end.month + 12 + delta
            if start_month > 12:
                start_month -= 12
                end_month -= 12
            if start_month > gregorian_start.month:
                years -= 1
        else:
            start_month = gregorian_start.month + delta
            end_month = gregorian_start.month + delta
            if start_month > 12:
                start_month -= 12
                end_month -= 12
                years += 1
        start_year = gregorian_start.year + years
        end_year = gregorian_start.year + years
        start_time = gregorian_start.replace(year=start_year,
                                             month=start_month)
        end_time = gregorian_end.replace(year=end_year, month=end_month)
        return TimePeriod(period.time_type, start_time.to_time(),
                          end_time.to_time())
    except ValueError:
        return None
Exemplo n.º 3
0
def move_period_num_months(period, num):
    try:
        delta = num
        years = abs(delta) / 12
        gregorian_start = gregorian.from_time(period.start_time)
        gregorian_end = gregorian.from_time(period.end_time)
        if num < 0:
            years = -years
        delta = delta - 12 * years
        if delta < 0:
            start_month = gregorian_start.month + 12 + delta
            end_month = gregorian_end.month + 12 + delta
            if start_month > 12:
                start_month -=12
                end_month -=12
            if start_month > gregorian_start.month:
                years -= 1
        else:
            start_month = gregorian_start.month + delta
            end_month = gregorian_start.month + delta
            if start_month > 12:
                start_month -=12
                end_month -=12
                years += 1
        start_year = gregorian_start.year + years
        end_year = gregorian_start.year + years
        start_time = gregorian_start.replace(year=start_year, month=start_month)
        end_time = gregorian_end.replace(year=end_year, month=end_month)
        return TimePeriod(period.time_type, start_time.to_time(), end_time.to_time())
    except ValueError:
        return None
Exemplo n.º 4
0
def _whole_number_of_months(period):
    """
    >>> from specs.utils import gregorian_period
    >>> from specs.utils import install_gettext_in_builtin_namespace

    >>> _whole_number_of_months(gregorian_period("1 Jan 2013", "1 Jan 2014"))
    True
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_months(gregorian_period("1 Jan 2013", "1 Mar 2014"))
    True
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_months(gregorian_period("2 Jan 2013", "2 Mar 2014"))
    False
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_months(gregorian_period("1 Jan 2013 12:00", "1 Mar 2014"))
    False
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _
    """
    start, end = gregorian.from_time(period.start_time), gregorian.from_time(period.end_time)
    start_months = start.year * 12 + start.month
    end_months = end.year * 12 + end.month
    month_diff = end_months - start_months
    return (start.is_first_of_month() and
            end.is_first_of_month() and
            month_diff > 0)
Exemplo n.º 5
0
 def navigate(tp):
     start = gregorian.from_time(curret_period.start_time)
     end = gregorian.from_time(curret_period.end_time)
     start_months = start.year * 12 + start.month
     end_months = end.year * 12 + end.month
     month_diff = end_months - start_months
     month_delta = month_diff * direction
     new_start_year, new_start_month = _months_to_year_and_month(
         start_months + month_delta)
     new_end_year, new_end_month = _months_to_year_and_month(end_months +
                                                             month_delta)
     try:
         new_start = start.replace(year=new_start_year,
                                   month=new_start_month)
         new_end = end.replace(year=new_end_year, month=new_end_month)
         start = new_start.to_time()
         end = new_end.to_time()
         if end > curret_period.time_type.get_max_time()[0]:
             raise ValueError()
         if start < curret_period.time_type.get_min_time()[0]:
             raise ValueError()
     except ValueError:
         if direction < 0:
             raise TimeOutOfRangeLeftError()
         else:
             raise TimeOutOfRangeRightError()
     return tp.update(start, end)
Exemplo n.º 6
0
 def label(self, time, major=False):
     if major:
         day_of_week = time.get_day_of_week()
         time = gregorian.from_time(time)
         return "%s %s %s %s" % (
             abbreviated_name_of_weekday(day_of_week), time.day,
             abbreviated_name_of_month(time.month), format_year(time.year))
     return (abbreviated_name_of_weekday(time.get_day_of_week()) +
             " %s" % gregorian.from_time(time).day)
Exemplo n.º 7
0
 def label(self, time, major=False):
     if major:
         day_of_week = time.get_day_of_week()
         time = gregorian.from_time(time)
         return "%s %s %s %s" % (abbreviated_name_of_weekday(day_of_week),
                                 time.day,
                                 abbreviated_name_of_month(time.month),
                                 format_year(time.year))
     return (abbreviated_name_of_weekday(time.get_day_of_week()) +
             " %s" % gregorian.from_time(time).day)
Exemplo n.º 8
0
def move_period_num_years(period, num):
    try:
        delta = num
        start_year = gregorian.from_time(period.start_time).year
        end_year = gregorian.from_time(period.end_time).year
        start_time = gregorian.from_time(period.start_time).replace(year=start_year + delta)
        end_time = gregorian.from_time(period.end_time).replace(year=end_year + delta)
        return TimePeriod(period.time_type, start_time.to_time(), end_time.to_time())
    except ValueError:
        return None
Exemplo n.º 9
0
def move_period_num_years(period, num):
    try:
        delta = num
        start_year = gregorian.from_time(period.start_time).year
        end_year = gregorian.from_time(period.end_time).year
        start_time = gregorian.from_time(
            period.start_time).replace(year=start_year + delta)
        end_time = gregorian.from_time(period.end_time).replace(year=end_year +
                                                                delta)
        return TimePeriod(period.time_type, start_time.to_time(),
                          end_time.to_time())
    except ValueError:
        return None
Exemplo n.º 10
0
 def _time_range_string(self, start, end):
     start = gregorian.from_time(start)
     end = gregorian.from_time(end)
     if start.year == end.year:
         if start.month == end.month:
             return "%s-%s %s %s" % (start.day, end.day,
                                     abbreviated_name_of_month(start.month),
                                     format_year(start.year))
         return "%s %s-%s %s %s" % (
             start.day, abbreviated_name_of_month(start.month), end.day,
             abbreviated_name_of_month(end.month), format_year(start.year))
     return "%s %s %s-%s %s %s" % (
         start.day, abbreviated_name_of_month(
             start.month), format_year(start.year), end.day,
         abbreviated_name_of_month(end.month), format_year(end.year))
Exemplo n.º 11
0
 def on_up(self):
     max_year = gregorian.from_time(GregorianTimeType().get_max_time()[0]).year
     def increment_year(date):
         year, month, day = date
         if year < max_year - 1:
             return self._set_valid_day(year + 1, month, day)
         return date
     def increment_month(date):
         year, month, day = date
         if month < 12:
             return self._set_valid_day(year, month + 1, day)
         elif year < max_year - 1:
             return self._set_valid_day(year + 1, 1, day)
         return date
     def increment_day(date):
         year, month, day = date
         time = gregorian.from_date(year, month, day).to_time()
         if time <  GregorianTimeType().get_max_time()[0] - delta_from_days(1):
             return gregorian.from_time(time + delta_from_days(1)).to_date_tuple()
         return date
     if not self._current_date_is_valid():
         return
     selection = self.date_picker.GetSelection()
     current_date = self.get_value()
     if self._insertion_point_in_region(self.region_year):
         new_date = increment_year(current_date)
     elif self._insertion_point_in_region(self.region_month):
         new_date = increment_month(current_date)
     else:
         new_date = increment_day(current_date)
         self._save_preferred_day(new_date)
     if current_date != new_date:
         self._set_new_date_and_restore_selection(new_date, selection)
Exemplo n.º 12
0
 def label(self, time, major=False):
     time = gregorian.from_time(time)
     if major:
         return "%s %s %s %s" % (time.day,
                                 abbreviated_name_of_month(time.month),
                                 format_year(time.year), time.hour)
     return str(time.hour)
Exemplo n.º 13
0
 def label(self, time, major=False):
     time = gregorian.from_time(time)
     if major:
         return "%s %s %s" % (time.day,
                              abbreviated_name_of_month(time.month),
                              format_year(time.year))
     return str(time.day)
Exemplo n.º 14
0
 def decrement_month(date):
     year, month, day = date
     if month > 1:
         return self._set_valid_day(year, month - 1, day)
     elif year > gregorian.from_time(GregorianTimeType().get_min_time()[0]).year:
         return self._set_valid_day(year - 1, 12, day)
     return date
Exemplo n.º 15
0
 def adjust_for_bc_years(self, time):
     gregorian_time = gregorian.from_time(time)
     if self.major_strip_is_decade:
         if gregorian_time.year < 0:
             gregorian_time.year += 2
         elif gregorian_time.year < 10:
             gregorian_time.year += 1
     return gregorian_time.to_time()
Exemplo n.º 16
0
def fit_month_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    start = gregorian.from_date(mean.year, mean.month, 1).to_time()
    if mean.month == 12:
        end = gregorian.from_date(mean.year + 1, 1, 1).to_time()
    else:
        end = gregorian.from_date(mean.year, mean.month + 1, 1).to_time()
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 17
0
def fit_month_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    start = gregorian.from_date(mean.year, mean.month, 1).to_time()
    if mean.month == 12:
        end = gregorian.from_date(mean.year + 1, 1, 1).to_time()
    else:
        end = gregorian.from_date(mean.year, mean.month + 1, 1).to_time()
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 18
0
 def increment_day(date):
     year, month, day = date
     time = gregorian.from_date(year, month, day).to_time()
     if time < GregorianTimeType().get_max_time()[0] - delta_from_days(
             1):
         return gregorian.from_time(time +
                                    delta_from_days(1)).to_date_tuple()
     return date
Exemplo n.º 19
0
 def adjust_for_bc_years(self, time):
     gregorian_time = gregorian.from_time(time)
     if self.major_strip_is_decade:
         if gregorian_time.year < 0:
             gregorian_time.year += 2
         elif gregorian_time.year < 10:
             gregorian_time.year += 1
     return gregorian_time.to_time()
Exemplo n.º 20
0
 def decrement_month(date):
     year, month, day = date
     if month > 1:
         return self._set_valid_day(year, month - 1, day)
     elif year > gregorian.from_time(
             GregorianTimeType().get_min_time()[0]).year:
         return self._set_valid_day(year - 1, 12, day)
     return date
Exemplo n.º 21
0
def fit_century_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    if mean.year > get_century_max_year():
        year = get_century_max_year()
    else:
        year = max(get_min_year_containing_jan_1(), int(mean.year / 100) * 100)
    start = gregorian.from_date(year, 1, 1).to_time()
    end = gregorian.from_date(year + 100, 1, 1).to_time()
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 22
0
def fit_week_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    start = gregorian.from_date(mean.year, mean.month, mean.day).to_time()
    weekday = start.get_day_of_week()
    start = start - delta_from_days(weekday)
    if not main_frame.week_starts_on_monday():
        start = start - delta_from_days(1)
    end = start + delta_from_days(7)
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 23
0
 def on_return(self):
     try:
         self.time = self.time_picker.get_value()
         if not self.checkbox.IsChecked():
             gt = gregorian.from_time(self.time)
             gt.hour = 12
             self.time = gt.to_time()
     except ValueError, ex:
         display_error_message(ex_msg(ex))
Exemplo n.º 24
0
def fit_week_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    start = gregorian.from_date(mean.year, mean.month, mean.day).to_time()
    weekday = start.get_day_of_week()
    start = start - delta_from_days(weekday)
    if not main_frame.week_starts_on_monday():
        start = start - delta_from_days(1)
    end = start + delta_from_days(7)
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 25
0
def fit_century_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    if mean.year > get_century_max_year():
        year = get_century_max_year()
    else:
        year = max(get_min_year_containing_jan_1(), int(mean.year/100)*100)
    start = gregorian.from_date(year, 1, 1).to_time()
    end = gregorian.from_date(year + 100, 1, 1).to_time()
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 26
0
 def on_return(self):
     try:
         self.time = self.time_picker.get_value()
         if not self.checkbox.IsChecked():
             gt = gregorian.from_time(self.time)
             gt.hour = 12
             self.time = gt.to_time()
     except ValueError, ex:
         display_error_message(ex_msg(ex))
Exemplo n.º 27
0
 def _time_range_string(self, start, end):
     start = gregorian.from_time(start)
     end = gregorian.from_time(end)
     if start.year == end.year:
         if start.month == end.month:
             return "%s-%s %s %s" % (start.day, end.day,
                                     abbreviated_name_of_month(start.month),
                                     format_year(start.year))
         return "%s %s-%s %s %s" % (start.day,
                                    abbreviated_name_of_month(start.month),
                                    end.day,
                                    abbreviated_name_of_month(end.month),
                                    format_year(start.year))
     return "%s %s %s-%s %s %s" % (start.day,
                                   abbreviated_name_of_month(start.month),
                                   format_year(start.year),
                                   end.day,
                                   abbreviated_name_of_month(end.month),
                                   format_year(end.year))
Exemplo n.º 28
0
 def navigate(tp):
     year_delta = direction * _calculate_year_diff(curret_period)
     gregorian_start = gregorian.from_time(curret_period.start_time)
     gregorian_end = gregorian.from_time(curret_period.end_time)
     new_start_year = gregorian_start.year + year_delta
     new_end_year = gregorian_end.year + year_delta
     try:
         new_start = gregorian_start.replace(year=new_start_year).to_time()
         new_end = gregorian_end.replace(year=new_end_year).to_time()
         if new_end > curret_period.time_type.get_max_time()[0]:
             raise ValueError()
         if new_start < curret_period.time_type.get_min_time()[0]:
             raise ValueError()
     except ValueError:
         if direction < 0:
             raise TimeOutOfRangeLeftError()
         else:
             raise TimeOutOfRangeRightError()
     return tp.update(new_start, new_end)
Exemplo n.º 29
0
 def __init__(self):
     self.db = MemoryDB()
     from timelinelib.time.gregoriantime import GregorianTimeType
     self.db.time_type = GregorianTimeType()
     now = gregorian.from_time(self.db.time_type.now())
     self.start = self.get_time(now.year, now.month, 1)
     self.end = self.start + self.get_days_delta(30)
     self.db._set_displayed_period(TimePeriod(self.db.get_time_type(),
                                              self.start, self.end))
     self.last_cat = None
Exemplo n.º 30
0
 def navigate(tp):
     year_delta = direction * _calculate_year_diff(curret_period)
     gregorian_start = gregorian.from_time(curret_period.start_time)
     gregorian_end = gregorian.from_time(curret_period.end_time)
     new_start_year = gregorian_start.year + year_delta
     new_end_year = gregorian_end.year + year_delta
     try:
         new_start = gregorian_start.replace(year=new_start_year).to_time()
         new_end = gregorian_end.replace(year=new_end_year).to_time()
         if new_end > curret_period.time_type.get_max_time()[0]:
             raise ValueError()
         if new_start < curret_period.time_type.get_min_time()[0]:
             raise ValueError()
     except ValueError:
         if direction < 0:
             raise TimeOutOfRangeLeftError()
         else:
             raise TimeOutOfRangeRightError()
     return tp.update(new_start, new_end)
Exemplo n.º 31
0
 def label(self, time, major=False):
     if major:
         # TODO: This only works for English. Possible to localize?
         time = gregorian.from_time(time)
         start_year = self._century_start_year(time.year)
         century = (start_year + 100) / 100
         if century <= 0:
             return str(abs(century - 1)) + " century BC"
         else:
             return str(century) + " century"
     return ""
Exemplo n.º 32
0
 def label(self, time, major=False):
     if major:
         # TODO: This only works for English. Possible to localize?
         time = gregorian.from_time(time)
         start_year = self._century_start_year(time.year)
         century = (start_year + 100) / 100
         if century <= 0:
             return str(abs(century - 1)) + " century BC"
         else:
             return str(century) + " century"
     return ""
Exemplo n.º 33
0
def _whole_number_of_years(period):
    """
    >>> from specs.utils import gregorian_period
    >>> from specs.utils import install_gettext_in_builtin_namespace

    >>> _whole_number_of_years(gregorian_period("1 Jan 2013", "1 Jan 2014"))
    True
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_years(gregorian_period("1 Jan 2013", "1 Jan 2015"))
    True
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_years(gregorian_period("1 Feb 2013", "1 Feb 2014"))
    False
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_years(gregorian_period("1 Jan 2013", "1 Feb 2014"))
    False
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _
    """
    return (gregorian.from_time(period.start_time).is_jan_first() and
            gregorian.from_time(period.end_time).is_jan_first() and
            _calculate_year_diff(period) > 0)
Exemplo n.º 34
0
 def navigate(tp):
     start = gregorian.from_time(curret_period.start_time)
     end = gregorian.from_time(curret_period.end_time)
     start_months = start.year * 12 + start.month
     end_months = end.year * 12 + end.month
     month_diff = end_months - start_months
     month_delta = month_diff * direction
     new_start_year, new_start_month = _months_to_year_and_month(start_months + month_delta)
     new_end_year, new_end_month = _months_to_year_and_month(end_months + month_delta)
     try:
         new_start = start.replace(year=new_start_year, month=new_start_month)
         new_end = end.replace(year=new_end_year, month=new_end_month)
         start = new_start.to_time()
         end = new_end.to_time()
         if end > curret_period.time_type.get_max_time()[0]:
             raise ValueError()
         if start < curret_period.time_type.get_min_time()[0]:
             raise ValueError()
     except ValueError:
         if direction < 0:
             raise TimeOutOfRangeLeftError()
         else:
             raise TimeOutOfRangeRightError()
     return tp.update(start, end)
Exemplo n.º 35
0
def _whole_number_of_years(period):
    """
    >>> from specs.utils import gregorian_period
    >>> from specs.utils import install_gettext_in_builtin_namespace

    >>> _whole_number_of_years(gregorian_period("1 Jan 2013", "1 Jan 2014"))
    True
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_years(gregorian_period("1 Jan 2013", "1 Jan 2015"))
    True
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_years(gregorian_period("1 Feb 2013", "1 Feb 2014"))
    False
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _

    >>> _whole_number_of_years(gregorian_period("1 Jan 2013", "1 Feb 2014"))
    False
    >>> install_gettext_in_builtin_namespace() # Needed because REPL replaces _
    """
    return (gregorian.from_time(period.start_time).is_jan_first()
            and gregorian.from_time(period.end_time).is_jan_first()
            and _calculate_year_diff(period) > 0)
Exemplo n.º 36
0
    def on_up(self):
        max_year = gregorian.from_time(
            GregorianTimeType().get_max_time()[0]).year

        def increment_year(date):
            year, month, day = date
            if year < max_year - 1:
                return self._set_valid_day(year + 1, month, day)
            return date

        def increment_month(date):
            year, month, day = date
            if month < 12:
                return self._set_valid_day(year, month + 1, day)
            elif year < max_year - 1:
                return self._set_valid_day(year + 1, 1, day)
            return date

        def increment_day(date):
            year, month, day = date
            time = gregorian.from_date(year, month, day).to_time()
            if time < GregorianTimeType().get_max_time()[0] - delta_from_days(
                    1):
                return gregorian.from_time(time +
                                           delta_from_days(1)).to_date_tuple()
            return date

        if not self._current_date_is_valid():
            return
        selection = self.date_picker.GetSelection()
        current_date = self.get_value()
        if self._insertion_point_in_region(self.region_year):
            new_date = increment_year(current_date)
        elif self._insertion_point_in_region(self.region_month):
            new_date = increment_month(current_date)
        else:
            new_date = increment_day(current_date)
            self._save_preferred_day(new_date)
        if current_date != new_date:
            self._set_new_date_and_restore_selection(new_date, selection)
Exemplo n.º 37
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 = gregorian.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 = delta_from_days(d)
    navigation_fn(lambda tp: tp.move_delta(direction*mv))
Exemplo n.º 38
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 = gregorian.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 = delta_from_days(d)
    navigation_fn(lambda tp: tp.move_delta(direction * mv))
Exemplo n.º 39
0
 def start(self, time):
     gregorian_time = gregorian.from_time(time)
     new_gregorian = gregorian.from_date(gregorian_time.year, gregorian_time.month, gregorian_time.day)
     return new_gregorian.to_time()
Exemplo n.º 40
0
 def start(self, time):
     gregorian_time = gregorian.from_time(time)
     new_gregorian = gregorian.from_date(
         self._decade_start_year(gregorian_time.year), 1, 1)
     return new_gregorian.to_time()
Exemplo n.º 41
0
def fit_day_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    start = gregorian.from_date(mean.year, mean.month, mean.day).to_time()
    end = start + delta_from_days(1)
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 42
0
 def increment(self, time):
     days_in_month = gregorian.from_time(time).days_in_month()
     return time + delta_from_days(days_in_month)
Exemplo n.º 43
0
 def increment(self, time):
     gregorian_time = gregorian.from_time(time)
     return gregorian_time.replace(year=gregorian_time.year + 1).to_time()
Exemplo n.º 44
0
def fit_year_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    start = gregorian.from_date(mean.year, 1, 1).to_time()
    end = gregorian.from_date(mean.year + 1, 1, 1).to_time()
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 45
0
 def increment(self, time):
     gregorian_time = gregorian.from_time(time)
     return gregorian_time.replace(year=gregorian_time.year + 1).to_time()
Exemplo n.º 46
0
 def time_to_wx_date(self, time):
     year, month, day = gregorian.from_time(time).to_date_tuple()
     return wx.DateTimeFromDMY(day, month - 1, year, 0, 0, 0)
Exemplo n.º 47
0
 def label_without_time(time):
     gregorian_datetime = gregorian.from_time(time)
     return u"%s %s %s" % (gregorian_datetime.day, abbreviated_name_of_month(gregorian_datetime.month), gregorian_datetime.year)
Exemplo n.º 48
0
 def start(self, time):
     gregorian_time = gregorian.from_time(time)
     new_gregorian = gregorian.from_date(gregorian_time.year,
                                         gregorian_time.month,
                                         gregorian_time.day)
     return new_gregorian.to_time()
Exemplo n.º 49
0
 def label(self, time, major=False):
     time = gregorian.from_time(time)
     return format_decade(self._decade_start_year(time.year))
Exemplo n.º 50
0
def fit_day_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    start = gregorian.from_date(mean.year, mean.month, mean.day).to_time()
    end = start + delta_from_days(1)
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 51
0
 def time_string(self, time):
     return "%d-%02d-%02d %02d:%02d:%02d" % gregorian.from_time(time).to_tuple()
Exemplo n.º 52
0
 def label(self, time, major=False):
     return format_year(gregorian.from_time(time).year)
Exemplo n.º 53
0
 def start(self, time):
     time = gregorian.from_time(time)
     return gregorian.from_date(self._century_start_year(time.year), 1, 1).to_time()
Exemplo n.º 54
0
def fit_decade_fn(main_frame, current_period, navigation_fn):
    mean = gregorian.from_time(current_period.mean_time())
    start = gregorian.from_date(int(mean.year/10)*10, 1, 1).to_time()
    end = gregorian.from_date(int(mean.year/10)*10+10, 1, 1).to_time()
    navigation_fn(lambda tp: tp.update(start, end))
Exemplo n.º 55
0
 def set_value(self, time):
     if time == None:
         time = self.now_fn()
     self.date_picker.set_value(gregorian.from_time(time).to_date_tuple())
     self.time_picker.set_value(gregorian.from_time(time).to_time_tuple())
Exemplo n.º 56
0
 def label(self, time, major=False):
     time = gregorian.from_time(time)
     return format_decade(self._decade_start_year(time.year))
Exemplo n.º 57
0
 def start(self, time):
     gregorian_time = gregorian.from_time(time)
     new_gregorian = gregorian.from_date(self._decade_start_year(gregorian_time.year), 1, 1)
     return new_gregorian.to_time()
Exemplo n.º 58
0
 def label(self, time, major=False):
     return format_year(gregorian.from_time(time).year)
Exemplo n.º 59
0
 def increment(self, time):
     days_in_month = gregorian.from_time(time).days_in_month()
     return time + delta_from_days(days_in_month)
Exemplo n.º 60
0
 def start(self, time):
     time = gregorian.from_time(time)
     return gregorian.from_date(self._century_start_year(time.year), 1,
                                1).to_time()