'Return estimate of next time to run.
Returns:
~datetime.timedelta: when the periodic task should
run next, or if it shouldn\'t run today (e.g., the sun does
not rise today), returns the time when the next check
should take place.'

def remaining_estimate(self, last_run_at):

    last_run_at = self.maybe_make_aware(last_run_at)
    last_run_at_utc = localize(last_run_at, timezone.utc)
    self.cal.date = last_run_at_utc
    try:
        if self.use_center:
            next_utc = getattr(self.cal, self.method)(self.ephem.Sun(), start=last_run_at_utc, use_center=self.use_center)
        else:
            next_utc = getattr(self.cal, self.method)(self.ephem.Sun(), start=last_run_at_utc)
    except self.ephem.CircumpolarError:
        next_utc = (self.cal.next_antitransit(self.ephem.Sun()) + timedelta(minutes=1))
    next = self.maybe_make_aware(next_utc.datetime())
    now = self.maybe_make_aware(self.now())
    delta = (next - now)
    return delta
