Exemplo n.º 1
0
 def testUTCDayTimeConversions(self):
     """Tests the UTC Datetime conversion, using timezone and utcoffsets"""
     bangkok_tz = get_timezone('GMT +7:00')
     now_in_bangkok = to_datetime(datetime(2009, 7, 11, 2, 30, tzinfo=bangkok_tz))
     midnight_in_bangkok = dt.midnight(now_in_bangkok)
     midnight_in_bangkok_as_utc = dt.midnight_with_utc_shift(now_in_bangkok)
     self.assert_equals(midnight_in_bangkok, midnight_in_bangkok_as_utc)
Exemplo n.º 2
0
 def _get_today_data(self, start, end, tz):
     if not (start <= now(tz) <= end):
         return []
     
     # Now is already calculated in the given timezone so we have to get
     # the midnight in that timezone, shifted to UTC time
     # TODO: this is being shifted later, does midnight suffice?
     today_midnight = midnight_with_utc_shift(now(tz))
     return [DayMarker(today_midnight)]
Exemplo n.º 3
0
 def _get_weekend_starts(self, start, end, tz):
     weekend_data = []
     # The start is stored in UTC but the weekend should be drawn
     # localized
     day = start.astimezone(tz)
     while day < end:
         if day.isoweekday() in (6, 7):
             weekend_start = midnight_with_utc_shift(day)
             weekend_data.append(DayMarker(weekend_start))
         day += timedelta(days=1)
     return weekend_data