def start(self, time): if self.appearance.get_week_start() == "monday": days_to_subtract = GregorianTimeType().get_day_of_week(time) else: # It is sunday days_to_subtract = (GregorianTimeType().get_day_of_week(time) + 1) % 7 return GregorianTime(time.julian_day - days_to_subtract, 0)
def time_to_wx_date(self, time): year, month, day = GregorianDateTime.from_time(time).to_date_tuple() try: return wx.DateTimeFromDMY(day, month - 1, year, 0, 0, 0) except OverflowError: if year < 0: year, month, day = GregorianDateTime.from_time( GregorianTime(0, 0)).to_date_tuple() return wx.DateTimeFromDMY(day, month - 1, year, 0, 0, 0)
def choose_strip(self, metrics, appearance): """ Return a tuple (major_strip, minor_strip) for current time period and window size. """ day_period = TimePeriod(GregorianTime(0, 0), GregorianTime(1, 0)) one_day_width = metrics.calc_exact_width(day_period) if one_day_width > 20000: return (StripHour(), StripMinute()) elif one_day_width > 600: return (StripDay(), StripHour()) elif one_day_width > 45: return (StripWeek(appearance), StripWeekday()) elif one_day_width > 25: return (StripMonth(), StripDay()) elif one_day_width > 1.5: return (StripYear(), StripMonth()) elif one_day_width > 0.12: return (StripDecade(), StripYear()) elif one_day_width > 0.012: return (StripCentury(), StripDecade()) else: return (StripCentury(), StripCentury())
def get_min_time(self): return GregorianTime.min()
def start(self, time): (hours, minutes, _) = time.get_time_of_day() return GregorianTime(time.julian_day, minutes * 60 + hours * 60 * 60)
def get_max_time(self): return GregorianTime(5369833, 0)
def get_min_time(self): return GregorianTime.min()
def to_time(self): days = gregorian_ymd_to_julian_day(self.year, self.month, self.day) seconds = self.hour * 60 * 60 + self.minute * 60 + self.second return GregorianTime(days, seconds)
def set_active(self, value): self.active = value GregorianTime.set_min_julian_day(value)