示例#1
0
 def test_GMT(self):
     gmt = GeoLocation.GMT()
     self.assertEqual(gmt.location_name, 'Greenwich, England')
     self.assertEqual(gmt.longitude, 0)
     self.assertEqual(gmt.latitude, 51.4772)
     self.assertTrue(gmt.time_zone._filename.endswith('/GMT'))
     self.assertEqual(gmt.elevation, 0)
示例#2
0
 def __init__(self, geo_location: Optional[GeoLocation] = None, date: Optional[date] = None, calculator: Optional[AstronomicalCalculations] = None):
     if geo_location is None:
         geo_location = GeoLocation.GMT()
     if date is None:
         date = datetime.today()
     if calculator is None:
         calculator = NOAACalculator()
     self.geo_location = geo_location
     self.date = date
     self.astronomical_calculator = calculator
示例#3
0
 def test_standard_time_offset_for_standard_timezone(self):
     geo = GeoLocation.GMT()
     geo.time_zone = 'America/New_York'
     self.assertEqual(geo.standard_time_offset(), -5 * GeoLocation.HOUR_MILLIS)
示例#4
0
 def test_standard_time_offset_for_gmt(self):
     geo = GeoLocation.GMT()
     self.assertEqual(geo.standard_time_offset(), 0)
示例#5
0
 def test_local_mean_time_offset_for_gmt(self):
     geo = GeoLocation.GMT()
     self.assertEqual(geo.local_mean_time_offset(), 0)
示例#6
0
 def test_antimeridian_adjustment_for_westward_crossover(self):
     geo = GeoLocation.GMT()
     geo.longitude = 179
     geo.time_zone = 'Etc/GMT+12'
     self.assertEqual(geo.antimeridian_adjustment(), 1)
示例#7
0
 def test_antimeridian_adjustment_for_standard_timezone(self):
     geo = GeoLocation.GMT()
     geo.time_zone = 'America/New_York'
     self.assertEqual(geo.antimeridian_adjustment(), 0)
示例#8
0
 def test_antimeridian_adjustment_for_gmt(self):
     geo = GeoLocation.GMT()
     self.assertEqual(geo.antimeridian_adjustment(), 0)
示例#9
0
 def test_time_zone_with_timezone_object(self):
     geo = GeoLocation.GMT()
     geo.time_zone = tz.gettz('America/New_York')
     self.assertTrue(geo.time_zone._filename.endswith('/America/New_York'))
示例#10
0
 def test_time_zone_with_string(self):
     geo = GeoLocation.GMT()
     geo.time_zone = 'America/New_York'
     self.assertTrue(geo.time_zone._filename.endswith('/America/New_York'))
示例#11
0
 def test_longitude_cartography_west(self):
     geo = GeoLocation.GMT()
     geo.longitude = 41, 7, 5.17296, 'W'
     self.assertEqual(geo.longitude, -41.1181036)
示例#12
0
 def test_longitude_numeric(self):
     geo = GeoLocation.GMT()
     geo.longitude = 23.4
     self.assertEqual(geo.longitude, 23.4)
示例#13
0
 def test_latitude_cartography_south(self):
     geo = GeoLocation.GMT()
     geo.latitude = 41, 7, 5.17296, 'S'
     self.assertEqual(geo.latitude, -41.1181036)
示例#14
0
 def test_latitude_numeric(self):
     geo = GeoLocation.GMT()
     geo.latitude = 33.3
     self.assertEqual(geo.latitude, 33.3)