我有这段代码来计算太阳的位置,但不依赖于DST。我必须在Sunset_time-5到Sunset_time-4之间的每个DST开关上进行更改 可以使用时区的某个模块来完成此操作吗? 谢谢。
class sunClass():
def __init__(self):
self.home = ephem.Observer()
self.home.lat = '45.xxxxx'
self.home.long = '-73.xxxxx'
self.home.elevation = 35
self.home.pressure = 0
self.home.horizon = '-3' #'-6' # civil twilight = -6 deg
# nautical = -12
# astronomical = -18
self.sun = ephem.Sun(self.home)
def getStat(self):
return self.home.previous_rising(self.sun) > self.home.previous_setting(self.sun) # get sun position
def getSunset(self):
sunset_time = self.home.next_setting(self.sun)
sunset_local_time = ephem.Date(sunset_time - 5 * ephem.hour) #local time
return sunset_local_time
def getSunrise(self):
sunrise_time = self.home.previous_rising(self.sun)
sunrise_local_time = ephem.Date(sunset_time - 5 * ephem.hour) #local time
return sunrise_local_time