def molad_as_datetime(self) -> datetime:
        m = self.molad()
        location_name = 'Jerusalem, Israel'
        latitude = 31.778  # Har Habayis latitude
        longitude = 35.2354  # Har Habayis longitude
        zone = tz.gettz('Asia/Jerusalem')

        geo = GeoLocation(location_name, latitude, longitude, zone)
        seconds = m.molad_chalakim * 10 / 3.0
        seconds, microseconds = divmod(seconds * 10**6, 10**6)
        # molad as local mean time
        time = datetime(m.gregorian_year,
                        m.gregorian_month,
                        m.gregorian_day,
                        m.molad_hours,
                        m.molad_minutes,
                        int(seconds),
                        int(microseconds),
                        tzinfo=tz.gettz('Etc/GMT-2'))
        # molad as Jerusalem standard time
        micro_offset = geo.local_mean_time_offset() * 1000
        time -= timedelta(microseconds=micro_offset)
        # molad as UTC
        return time.astimezone(tz.UTC)
示例#2
0
 def test_local_mean_time_offset_west_of_center_meridian(self):
     geo = GeoLocation('Sample', 40, -76.25, 'America/New_York')
     self.assertEqual(geo.local_mean_time_offset(), -1.25 * 4 * GeoLocation.MINUTE_MILLIS)
示例#3
0
 def test_local_mean_time_offset_on_center_meridian(self):
     geo = GeoLocation('Sample', 40, -75, 'America/New_York')
     self.assertEqual(geo.local_mean_time_offset(), 0)