Returns the date of the next sunrise.
557068
def nextSunrise(date, pos):
    
    jd = eph.nextSunrise(date.jd, pos.lat, pos.lon)
    return Datetime.fromJD(jd, date.utcoffset)
1346374
def pyephem_earthsun_distance(time):
    

    import ephem

    sun = ephem.Sun()
    earthsun = []
    for thetime in time:
        sun.compute(ephem.Date(thetime))
        earthsun.append(sun.earth_distance)

    return pd.Series(earthsun, index=time)
602869
def isDiurnal(self):
        
        sun = self.getObject(const.SUN)
        mc = self.getAngle(const.MC)
        
        # Get ecliptical positions and check if the
        # sun is above the horizon.
        lat = self.pos.lat
        sunRA, sunDecl = utils.eqCoords(sun.lon, sun.lat)
        mcRA, mcDecl = utils.eqCoords(mc.lon, 0)
        return utils.isAboveHorizon(sunRA, sunDecl, mcRA, lat)
1055313
def now(self):
        

        # From the comments in issue 19: forecast.days[0] is dated for the
        # previous day shortly after midnight

        now = None
        # Set the time now to be in the same time zone as the first timestep in
        # the forecast. This shouldn't cause problems with daylight savings as
        # the change is far enough after midnight.
        d = datetime.datetime.now(tz=self.days[0].date.tzinfo)
        # d is something like datetime.datetime(2019, 1, 19, 17, 5, 28, 337439)
        # d.replace(...) is datetime.datetime(2019, 1, 19, 0, 0)
        # for_total_seconds is then: datetime.timedelta(seconds=61528,
        #                                               microseconds=337439)
        # In this example, this is (17*60*60) + (5*60) + 28 = 61528
        # this is the number of seconds through the day
        for_total_seconds = d - \
            d.replace(hour=0, minute=0, second=0, microsecond=0)

        # In the example time,
        # for_total_seconds.total_seconds() = 61528 + 0.337439
        # This is the number of seconds after midnight
        # msm is then the number of minutes after midnight
        msm = for_total_seconds.total_seconds() / 60

        # If the date now and the date in the forecast are the same, proceed
        if self.days[0].date.strftime("%Y-%m-%dZ") == d.strftime("%Y-%m-%dZ"):
            # We have determined that the date in the forecast and the date now
            # are the same.
            #
            # Now, test if timestep.name is larger than the number of minutes
            # since midnight for each timestep.
            # The timestep we keep is the one with the largest timestep.name
            # which is less than the number of minutes since midnight
            for timestep in self.days[0].timesteps:
                if timestep.name > msm:

                    # break here stops the for loop
                    break
                # now is assigned to the last timestep that did not break the
                # loop
                now = timestep
            return now
        # Bodge to get around problems near midnight:
        # Previous method does not account for the end of the month. The test
        # trying to be evaluated is that the absolute difference between the
        # last timestep of the first day and the current time is less than 4
        # hours. 4 hours is because the final timestep of the previous day is
        # for 21:00
        elif abs(self.days[0].timesteps[-1].date - d).total_seconds() < 14400:
            # This is verbose to check that the returned data makes sense
            timestep_to_return = self.days[0].timesteps[-1]

            return timestep_to_return
        else:
            return False
640775
def next_weekday(date):
    '''
    
    '''
    n_days = 7 - date.weekday()
    if n_days > 3:
        n_days = 1
    return date + datetime.timedelta(days=n_days)
54446
def get_future(self):
        """"""
        now = dt.now()
        four_days = now + timedelta(hours=96)
        now = now.timestamp()
        four_days = four_days.timestamp()
        url = build_url(self.api_key, self.spot_id, self.fields,
                        self.unit, now, four_days)
        return get_msw(url)
15785
protected Calendar guessCalendar() {
        ULocale calLocale = getAvailableLocale(TYPE_CALENDAR);
        if (calLocale == null) {
            calLocale = ULocale.US;
        }
        return Calendar.getInstance(getTimeZone(), calLocale);
    }
396882
public static Date nextHour(@NotNull final Date date) {
		return DateUtils.ceiling(date, Calendar.HOUR_OF_DAY);
	}
823425
public Date getTimeAfter(Date afterTime) {
    Calendar date = new GregorianCalendar();
    date.setTime(afterTime);

    Calendar after = getTimeAfter(date);

    return after == null ? null : after.getTime();
  }
109019
public static Date nextMinute(@NotNull final Date date) {
		return DateUtils.ceiling(date, Calendar.MINUTE);
	}
1180088
def prevSolarEclipse(date):
    

    eclipse = swe.solarEclipseGlobal(date.jd, backward=True)
    return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
112097
def next(pointer)
      super

      half_day = 60 * 60 * 12
      full_day = 60 * 60 * 24

      first = false

      unless @current_time
        first = true
        midnight = Chronic.time_class.local(@now.year, @now.month, @now.day)

        yesterday_midnight = midnight - full_day
        tomorrow_midnight = midnight + full_day

        offset_fix = midnight.gmt_offset - tomorrow_midnight.gmt_offset
        tomorrow_midnight += offset_fix

        catch :done do
          if pointer == :future
            if @type.ambiguous?
              [midnight + @type.time + offset_fix, midnight + half_day + @type.time + offset_fix, tomorrow_midnight + @type.time].each do |t|
                (@current_time = t; throw :done) if t >= @now
              end
            else
              [midnight + @type.time + offset_fix, tomorrow_midnight + @type.time].each do |t|
                (@current_time = t; throw :done) if t >= @now
              end
            end
          else # pointer == :past
            if @type.ambiguous?
              [midnight + half_day + @type.time + offset_fix, midnight + @type.time + offset_fix, yesterday_midnight + @type.time + half_day].each do |t|
                (@current_time = t; throw :done) if t <= @now
              end
            else
              [midnight + @type.time + offset_fix, yesterday_midnight + @type.time].each do |t|
                (@current_time = t; throw :done) if t <= @now
              end
            end
          end
        end

        @current_time || raise("Current time cannot be nil at this point")
      end

      unless first
        increment = @type.ambiguous? ? half_day : full_day
        @current_time += pointer == :future ? increment : -increment
      end

      Span.new(@current_time, @current_time + width)
    end
1126495
def calculate_sunrise_sunset(self, month, day, depression=0.833,
                                 is_solar_time=False):
        
        datetime = DateTime(month, day, hour=12, leap_year=self.is_leap_year)

        return self.calculate_sunrise_sunset_from_datetime(datetime,
                                                           depression,
                                                           is_solar_time)
1199164
def U(self):
    ""
    if getattr(self.data, 'tzinfo', None):
      return int(calendar.timegm(self.data.utctimetuple()))
    else:
      return int(time.mktime(self.data.timetuple()))
1318713
def next(self):
        '''
        
        '''
        if self.started is False:

            self.started = True
            now_ = datetime.now()
            if self.hour:
                # Fixed hour in a day
                # Next run will be the next day
                scheduled = now_.replace(hour=self.hour, minute=self.minute, second=self.second, microsecond=0)
                if scheduled == now_:
                    return timedelta(seconds=0)
                elif scheduled < now_:
                    # Scheduled time is passed
                    return scheduled.replace(day=now_.day + 1) - now_
            else:
                # Every hour in a day
                # Next run will be the next hour
                scheduled = now_.replace(minute=self.minute, second=self.second, microsecond=0)
                if scheduled == now_:
                    return timedelta(seconds=0)
                elif scheduled < now_:
                    # Scheduled time is passed
                    return scheduled.replace(hour=now_.hour + 1) - now_
            return scheduled - now_
        else:
            if self.hour:
                return timedelta(days=1)  # next day
            return timedelta(hours=1)
545623
def _next_opening_time(self, other):
        
        if not self.next_bday.onOffset(other):
            other = other + self.next_bday
        else:
            if self.n >= 0 and self.start < other.time():
                other = other + self.next_bday
            elif self.n < 0 and other.time() < self.start:
                other = other + self.next_bday
        return datetime(other.year, other.month, other.day,
                        self.start.hour, self.start.minute)
712087
def nextSunset(jd, lat, lon):
    
    return swe.sweNextTransit(const.SUN, jd, lat, lon, 'SET')