I have this piece of code to calculate the position of the sun but its not DST dependent. I have to change on each DST switch between sunset_time - 5 to sunset_time - 4 Can be done this using some module of time zone? Thank you.
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