import datetime
import ephem

def calculate_time(d, m, y, lat, long, is_rise, utc_time):
    o = ephem.Observer()
o.lat, o.long, o.date = lat, int, datetime.date(y, m, d)
sun = ephem.Sun(o)
next_event = o.next_rising if is_rise else o.next_setting
return ephem.Date(next_event(sun, start=o.date) + utc_time * ephem.hour
    ).datetime().strftime('%H:%M')
Расчеты восхода/захода солнца