import datetime
from suntime import Sun, SunTimeException
from datetime import timedelta
def day_night_time(lat,long,TO_date,TO_time):
sun = Sun(lat,long)
date = datetime.date(int(TO_date[:4]), int(TO_date[5:7]), int(TO_date[8:10]))
TO = datetime.datetime(int(TO_date[:4]), int(TO_date[5:7]), int(TO_date[8:10]),int(TO_time[:2]), int(TO_time[3:5]))
day_sr = sun.get_local_sunrise_time(date)
day_ss = sun.get_local_sunset_time(date)
n_end = day_sr - timedelta(minutes=30)
n_start = day_ss + timedelta(minutes=30)
print(TO)
print(n_end)
# print(TO-n_end)
day_night_time(50,20,'2020-06-24','10:45:00.000000')
returns
2020-06-24 10:45:00
2020-06-24 02:02:00+00:00
I am unable to use this as once has the +00:00 on the end. What is the best way to remove the +00:00 or add it to the other date, so that they can be used.
Currrent error: TypeError: can't subtract offset-naive and offset-aware datetimes
Many thanks for your help