Пример #1
0
 def test_jd_to_struct_time(self):
     # Check conversion of Julian Date number to AD date & time
     jd_ad = 2458227.9263194446  # As in `test_struct_time_to_jd`
     st_ad = struct_time([2018, 4, 19] + [10, 13, 54] +
                         convert.TIME_EMPTY_EXTRAS)
     self.assertEqual(st_ad, convert.jd_to_struct_time(jd_ad))
     # Check conversion of Julian Date number to BC date & time
     # WARNING: Converted time is off by 1 second, 53 not 54
     jd_bc = 984091.9263194444  # As in `test_struct_time_to_jd`
     st_bc = struct_time([-2018, 4, 19] + [10, 13, 54 - 1] +
                         convert.TIME_EMPTY_EXTRAS)
     self.assertEqual(st_bc, convert.jd_to_struct_time(jd_bc))
Пример #2
0
 def test_jd_to_struct_time(self):
     # Check conversion of Julian Date number to AD date & time
     jd_ad = 2458227.9263194446  # As in `test_struct_time_to_jd`
     st_ad = struct_time(
         [2018, 4, 19] + [10, 13, 54] + convert.TIME_EMPTY_EXTRAS)
     self.assertEqual(st_ad, convert.jd_to_struct_time(jd_ad))
     # Check conversion of Julian Date number to BC date & time
     # WARNING: Converted time is off by 1 second, 53 not 54
     jd_bc = 984091.9263194444  # As in `test_struct_time_to_jd`
     st_bc = struct_time(
         [-2018, 4, 19] + [10, 13, 54 - 1] + convert.TIME_EMPTY_EXTRAS)
     self.assertEqual(st_bc, convert.jd_to_struct_time(jd_bc))
Пример #3
0
 def test_jd_round_trip_for_2_bc(self):
     original_st = struct_time(
         [-1, 12, 5] + [4, 58, 59] + convert.TIME_EMPTY_EXTRAS)
     converted_st = convert.jd_to_struct_time(
         convert.struct_time_to_jd(original_st))
     self.assertEqual(
         (-1, 12, 5, 4, 58, 59, 0, 0, -1),
         tuple(converted_st))
Пример #4
0
 def test_jd_round_trip_for_extreme_future(self):
     original_st = struct_time([999999, 8, 4] + [21, 15, 3] +
                               convert.TIME_EMPTY_EXTRAS)
     jd = convert.struct_time_to_jd(original_st)
     converted_st = convert.jd_to_struct_time(jd)
     # Confirm that year, month, day, hour, minute are correct (not second)
     self.assertEqual(original_st[:5], converted_st[:5])
     # WARNING: Seconds are off by 1, should be 3 but is 2
     self.assertEqual(3 - 1, converted_st[5])
Пример #5
0
 def test_jd_round_trip_for_extreme_future(self):
     original_st = struct_time(
         [999999, 8, 4] + [21, 15, 3] + convert.TIME_EMPTY_EXTRAS)
     jd = convert.struct_time_to_jd(original_st)
     converted_st = convert.jd_to_struct_time(jd)
     # Confirm that year, month, day, hour, minute are correct (not second)
     self.assertEqual(original_st[:5], converted_st[:5])
     # WARNING: Seconds are off by 1, should be 3 but is 2
     self.assertEqual(3 - 1, converted_st[5])
Пример #6
0
 def test_jd_round_trip_for_extreme_past(self):
     original_st = struct_time(
         [-999999, 8, 4] + [21, 15, 3] + convert.TIME_EMPTY_EXTRAS)
     converted_st = convert.jd_to_struct_time(
         convert.struct_time_to_jd(original_st))
     # WARNING: We have lost a year of accuracy
     self.assertEqual(
         (-999999 + 1,  # Year off by 1
          8, 4, 21, 15, 3, 0, 0, -1),
         tuple(converted_st))
Пример #7
0
 def test_jd_round_trip_for_extreme_past(self):
     original_st = struct_time([-999999, 8, 4] + [21, 15, 3] +
                               convert.TIME_EMPTY_EXTRAS)
     converted_st = convert.jd_to_struct_time(
         convert.struct_time_to_jd(original_st))
     # WARNING: We have lost a year of accuracy
     self.assertEqual(
         (
             -999999 + 1,  # Year off by 1
             8,
             4,
             21,
             15,
             3,
             0,
             0,
             -1),
         tuple(converted_st))
Пример #8
0
 def test_jd_round_trip_for_2_bc(self):
     original_st = struct_time([-1, 12, 5] + [4, 58, 59] +
                               convert.TIME_EMPTY_EXTRAS)
     converted_st = convert.jd_to_struct_time(
         convert.struct_time_to_jd(original_st))
     self.assertEqual((-1, 12, 5, 4, 58, 59, 0, 0, -1), tuple(converted_st))