コード例 #1
0
 def test_sof_zman_kiddush_levana_between_moldos(self):
     calendar = JewishCalendar(5776, 8, 1)
     next_month = JewishCalendar(5776, 9, 1)
     first_molad = calendar.molad_as_datetime()
     second_molad = next_month.molad_as_datetime()
     expected_offset = (second_molad -
                        first_molad).total_seconds() * 10**6 / 2.0
     expected_time = first_molad + timedelta(microseconds=expected_offset)
     # round for floating microsecond precision inconsistency
     self.assertEqual(
         calendar.sof_zman_kiddush_levana_between_moldos().toordinal(),
         expected_time.toordinal())
コード例 #2
0
    def test_molad_as_datetime(self):
        expected_offset = (2, 20, 56, 496000
                           )  # UTC is 2:20:56.496 behind Jerusalem Local Time
        calendar = JewishCalendar(5776, 8, 1)
        hours, minutes, chalakim = 5, 51, 10
        seconds = (chalakim * 10 / 3.0)
        seconds, microseconds = divmod(seconds * 10**6, 10**6)
        hours -= expected_offset[0]
        minutes -= expected_offset[1]
        seconds -= expected_offset[2]
        microseconds -= expected_offset[3]

        total_seconds = (hours * 3600) + (minutes * 60) + seconds
        total_microseconds = (total_seconds * 10**6) + microseconds

        expected_molad = datetime(
            2015, 10, 13, 0, 0, 0,
            tzinfo=tz.UTC) + timedelta(microseconds=total_microseconds)
        self.assertEqual(calendar.molad_as_datetime(), expected_molad)