Calculate delta for daylight saving.
349755
def dst(self, dt):
        """"""
        # Daylight saving starts on the second Sunday of March at 2AM standard
        dst_start_date = self.first_sunday(dt.year, 3) + timedelta(days=7) \
                                                       + timedelta(hours=2)
        # Daylight saving ends on the first Sunday of November at 2AM standard
        dst_end_date = self.first_sunday(dt.year, 11) + timedelta(hours=2)

        if dst_start_date <= dt.replace(tzinfo=None) < dst_end_date:
            return timedelta(hours=1)
        else:
            return timedelta(0)
123944
private double getDeclination( double dayangb ) {
        double delta = .3723 + 23.2567 * Math.sin(dayangb) - .758 * Math.cos(dayangb) + .1149 * Math.sin(2 * dayangb) + .3656
                * Math.cos(2 * dayangb) - .1712 * Math.sin(3 * dayangb) + .0201 * Math.cos(3 * dayangb);
        return Math.toRadians(delta);
    }
660233
def I(self):
    "'"
    if self.timezone and self.timezone.dst(self.data):
      return u'1'
    else:
      return u'0'
460188
def _subtract_timedelta(self, delta):
        
        if isinstance(delta, pendulum.Duration):
            return self.subtract(
                years=delta.years,
                months=delta.months,
                weeks=delta.weeks,
                days=delta.remaining_days,
                hours=delta.hours,
                minutes=delta.minutes,
                seconds=delta.remaining_seconds,
                microseconds=delta.microseconds,
            )

        return self.subtract(
            days=delta.days, seconds=delta.seconds, microseconds=delta.microseconds
        )
373458
def calculate_deltat(year, month):
    

    plw = 'Deltat is unknown for years before -1999 and after 3000. ' \
          'Delta values will be calculated, but the calculations ' \
          'are not intended to be used for these years.'

    try:
        if np.any((year > 3000) | (year < -1999)):
            warnings.warn(plw)
    except ValueError:
        if (year > 3000) | (year < -1999):
            warnings.warn(plw)
    except TypeError:
        return 0

    y = year + (month - 0.5)/12

    deltat = np.where(year < -500,

                      -20+32*((y-1820)/100)**2, 0)

    deltat = np.where((-500 <= year) & (year < 500),

                      10583.6-1014.41*(y/100)
                      + 33.78311*(y/100)**2
                      - 5.952053*(y/100)**3
                      - 0.1798452*(y/100)**4
                      + 0.022174192*(y/100)**5
                      + 0.0090316521*(y/100)**6, deltat)

    deltat = np.where((500 <= year) & (year < 1600),

                      1574.2-556.01*((y-1000)/100)
                      + 71.23472*((y-1000)/100)**2
                      + 0.319781*((y-1000)/100)**3
                      - 0.8503463*((y-1000)/100)**4
                      - 0.005050998*((y-1000)/100)**5
                      + 0.0083572073*((y-1000)/100)**6, deltat)

    deltat = np.where((1600 <= year) & (year < 1700),

                      120-0.9808*(y-1600)
                      - 0.01532*(y-1600)**2
                      + (y-1600)**3/7129, deltat)

    deltat = np.where((1700 <= year) & (year < 1800),

                      8.83+0.1603*(y-1700)
                      - 0.0059285*(y-1700)**2
                      + 0.00013336*(y-1700)**3
                      - (y-1700)**4/1174000, deltat)

    deltat = np.where((1800 <= year) & (year < 1860),

                      13.72-0.332447*(y-1800)
                      + 0.0068612*(y-1800)**2
                      + 0.0041116*(y-1800)**3
                      - 0.00037436*(y-1800)**4
                      + 0.0000121272*(y-1800)**5
                      - 0.0000001699*(y-1800)**6
                      + 0.000000000875*(y-1800)**7, deltat)

    deltat = np.where((1860 <= year) & (year < 1900),

                      7.62+0.5737*(y-1860)
                      - 0.251754*(y-1860)**2
                      + 0.01680668*(y-1860)**3
                      - 0.0004473624*(y-1860)**4
                      + (y-1860)**5/233174, deltat)

    deltat = np.where((1900 <= year) & (year < 1920),

                      -2.79+1.494119*(y-1900)
                      - 0.0598939*(y-1900)**2
                      + 0.0061966*(y-1900)**3
                      - 0.000197*(y-1900)**4, deltat)

    deltat = np.where((1920 <= year) & (year < 1941),

                      21.20+0.84493*(y-1920)
                      - 0.076100*(y-1920)**2
                      + 0.0020936*(y-1920)**3, deltat)

    deltat = np.where((1941 <= year) & (year < 1961),

                      29.07+0.407*(y-1950)
                      - (y-1950)**2/233
                      + (y-1950)**3/2547, deltat)

    deltat = np.where((1961 <= year) & (year < 1986),

                      45.45+1.067*(y-1975)
                      - (y-1975)**2/260
                      - (y-1975)**3/718, deltat)

    deltat = np.where((1986 <= year) & (year < 2005),

                      63.86+0.3345*(y-2000)
                      - 0.060374*(y-2000)**2
                      + 0.0017275*(y-2000)**3
                      + 0.000651814*(y-2000)**4
                      + 0.00002373599*(y-2000)**5, deltat)

    deltat = np.where((2005 <= year) & (year < 2050),

                      62.92+0.32217*(y-2000)
                      + 0.005589*(y-2000)**2, deltat)

    deltat = np.where((2050 <= year) & (year < 2150),

                      -20+32*((y-1820)/100)**2
                      - 0.5628*(2150-y), deltat)

    deltat = np.where(year >= 2150,

                      -20+32*((y-1820)/100)**2, deltat)

    deltat = deltat.item() if np.isscalar(year) & np.isscalar(month)\
        else deltat

    return deltat
1307483
def delta(self,local=False):
        
        (s,e) = self.get(local)
        return e-s
751972
def get_due(self, estimated):
        """"""
        due = 0
        due = round((estimated - datetime.utcnow()).seconds / 60)
        return due
367202
def date_and_delta(value):
    """"""
    now = _now()
    if isinstance(value, datetime):
        date = value
        delta = now - value
    elif isinstance(value, timedelta):
        date = now - value
        delta = value
    else:
        try:
            value = int(value)
            delta = timedelta(seconds=value)
            date = now - delta
        except (ValueError, TypeError):
            return (None, value)
    return date, abs_timedelta(delta)
1041897
def total_seconds(delta):
    
    try:
        return delta.total_seconds()
    except AttributeError:
        return ((delta.days * 24 * 3600) + delta.seconds +
                float(delta.microseconds) / (10 ** 6))
240261
def _inc_lat(self, latitude, delta):
        """"""
        y = self._convert_latitude(latitude)
        y += delta
        return 360 / pi * atan(
            exp((180 - y * 360 / (2 ** self._zoom) / self._size) * pi / 180)) - 90
883766
def delta(self):
        """"""
        end_time = self.end_time if self.end_time else dt.datetime.now()
        return end_time - self.start_time
1101323
public void plusDays(long delta)
    {
        if (delta != 0)
        {
            long result = getDay() + delta;
            if (result >= 1 && result <= 28)
            {
                setDay((int) result);
            }
            else
            {
                ZonedDateTime zonedDateTime = ZonedDateTime.from(this);
                ZonedDateTime plusDays = zonedDateTime.plusDays(delta);
                set(plusDays);
            }
        }
    }
1234589
def getDateFromToday(delta,strfmt='%Y%m%d'):
	
	return (dt.date.today() + dt.timedelta(delta)).strftime(strfmt)
581664
def _delta_time(self, date_time):
        
        now = datetime.datetime.now(tzlocal())
        diff = date_time - now

        days = int(diff.days)
        hours = int(diff.seconds / 3600)
        minutes = int((diff.seconds / 60) - (hours * 60)) + 1
        total_minutes = int((diff.seconds / 60) + (days * 24 * 60)) + 1

        return {
            "days": days,
            "hours": hours,
            "minutes": minutes,
            "total_minutes": total_minutes,
        }
192539
def datetime2ole(dt):
    """"""
    delta = dt - OLE_TIME_ZERO
    delta_float = delta / datetime.timedelta(days=1)  # trick from SO
    return delta_float
312017
def unix_time(self, dt):
        
        epoch = datetime.utcfromtimestamp(0)
        delta = dt - epoch
        return int(delta.total_seconds())
1338409
def advance_time_delta(timedelta):
    """"""
    assert(utcnow.override_time is not None)
    try:
        for dt in utcnow.override_time:
            dt += timedelta
    except TypeError:
        utcnow.override_time += timedelta