예제 #1
0
 def start(self, time):
     if self.config.week_start == "monday":
         days_to_subtract = time.get_day_of_week()
     else:
         # It is sunday
         days_to_subtract = (time.get_day_of_week() + 1) % 7
     return timeline.Time(time.julian_day - days_to_subtract, 0)
예제 #2
0
 def choose_strip(self, metrics, config):
     """
     Return a tuple (major_strip, minor_strip) for current time period and
     window size.
     """
     day_period = TimePeriod(self, timeline.Time(0, 0), timeline.Time(1, 0))
     one_day_width = metrics.calc_exact_width(day_period)
     self.major_strip_is_decade = False
     if one_day_width > 600:
         return (StripDay(), StripHour())
     elif one_day_width > 45:
         return (StripWeek(config), StripWeekday())
     elif one_day_width > 25:
         return (StripMonth(), StripDay())
     elif one_day_width > 1.5:
         return (StripYear(), StripMonth())
     elif one_day_width > 0.12:
         self.major_strip_is_decade = True
         return (StripDecade(), StripYear())
     elif one_day_width > 0.012:
         return (StripCentury(), StripDecade())
     else:
         return (StripCentury(), StripCentury())
예제 #3
0
 def start(self, time):
     (hours, minutes, seconds) = time.get_time_of_day()
     return timeline.Time(time.julian_day, hours * 60 * 60)
예제 #4
0
 def get_max_time(self):
     return (timeline.Time(5369833, 0), _("can't be after year 9989"))
예제 #5
0
 def get_min_time(self):
     return (timeline.Time(0, 0), _("can't be before year 10"))
예제 #6
0
 def to_time(self):
     days = to_julian_day(self.year, self.month, self.day)
     seconds = self.hour * 60 * 60 + self.minute * 60 + self.second
     return timeline.Time(days, seconds)