コード例 #1
0
 def test_parse(self):
     """Test parse."""
     res = Timing.parse("20180605_215959")
     self.assertEqual(
         time.struct_time(
             (2018, 6, 5, 21, 59, 59, 1, 156, -1)),
         res)
コード例 #2
0
 def is_backup_allowed_time(self, time):
     """
     >>> sample_data = BusinessHours._BusinessHours__sample_data()
     >>> sample_hours = BusinessHours.parse_tag_str(sample_data)
     >>> some_tuesday_evening = "20180605_215959"
     >>> sample_hours.is_backup_allowed_time(some_tuesday_evening)
     True
     >>> some_tuesday_noon = "20180605_115500"
     >>> sample_hours.is_backup_allowed_time(some_tuesday_noon)
     False
     >>> some_sunday_noon = "20180610_115500"
     >>> sample_hours.is_backup_allowed_time(some_sunday_noon)
     True
     """
     # time.struct_time.tm_wday is range [0, 6], Monday is 0
     t = Timing.parse(time)
     return self.is_backup_allowed_dh(day=1 + t.tm_wday, hour=t.tm_hour)