Computes how far TDB is in advance of TT, given TDB.

    Given that the two time scales never diverge by more than 2ms, TT
    can also be given as the argument to perform the conversion in the
    other direction.
167624
def tdb_minus_tt(jd_tdb):
    
    t = (jd_tdb - T0) / 36525.0

    # USNO Circular 179, eq. 2.6.
    return (0.001657 * sin ( 628.3076 * t + 6.2401)
          + 0.000022 * sin ( 575.3385 * t + 4.2970)
          + 0.000014 * sin (1256.6152 * t + 6.1969)
          + 0.000005 * sin ( 606.9777 * t + 4.0212)
          + 0.000005 * sin (  52.9691 * t + 0.4444)
          + 0.000002 * sin (  21.3299 * t + 5.5431)
          + 0.000010 * t * sin ( 628.3076 * t + 4.2490))
1173479
def get_min_from_t(self, timestamp):
        
        if self.is_time_valid(timestamp):
            return timestamp
        t_day_epoch = get_day(timestamp)
        tr_mins = self.get_min_sec_from_morning()
        return t_day_epoch + tr_mins
955508
public function farthest(ChronosInterface $dt1, ChronosInterface $dt2)
    {
        return $this->diffInSeconds($dt1) > $this->diffInSeconds($dt2) ? $dt1 : $dt2;
    }
1178156
def timediff(time):
    """"""
    now = datetime.datetime.utcnow()
    diff = now - time
    diff_sec = diff.total_seconds()
    return diff_sec
10719
@Trivial
    public static double relativeSeconds(long relativePointA, long relativePointB) {
        long diff = relativePointB - relativePointA;
        double seconds = toSeconds(diff);
        return seconds;
    }
1325756
def diff(self, dt=None, abs=True):
        
        if dt is None:
            dt = self.now(self.tz)

        return Period(self, dt, absolute=abs)
216680
public TimeDuration durationBetween(Timestamp time) {
        long nanoSecDiff = time.nanoSec - nanoSec;
        nanoSecDiff += (time.unixSec - unixSec) * 1000000000;
        nanoSecDiff = Math.abs(nanoSecDiff);
        return TimeDuration.ofNanos(nanoSecDiff);
    }
209877
@Override
    public int compareTo(ZonalTransition other) {

        long delta = (this.posix - other.posix);

        if (delta == 0) {
            delta = (this.previous - other.previous);
            if (delta == 0) {
                delta = (this.total - other.total);
                if (delta == 0) {
                    delta = (this.getDaylightSavingOffset() - other.getDaylightSavingOffset());
                    if (delta == 0) {
                        return 0;
                    }
                }
            }
        }

        return ((delta < 0) ? -1 : 1);

    }
716819
function compareDates(a, b) {
    var aTimestamp = convertToTimestamp(a);
    var bTimestamp = convertToTimestamp(b);

    if (isNaN(aTimestamp) || isNaN(bTimestamp)) {
      return NaN;
    } else {
      return aTimestamp - bTimestamp;
    }
  }
743975
def closest(self, dt1, dt2, *dts):
        from functools import reduce

        
        dt1 = pendulum.instance(dt1)
        dt2 = pendulum.instance(dt2)
        dts = [dt1, dt2] + [pendulum.instance(x) for x in dts]
        dts = [(abs(self - dt), dt) for dt in dts]

        return min(dts)[1]
104847
def _get_timethresh_heuristics(self):
        
        if self.length > 1E5:
            time_thresh = 2.5
        elif self.length > 1E4:
            time_thresh = 2.0
        elif self.length > 1E3:
            time_thresh = 1.0
        else:
            time_thresh = 0.5
        return time_thresh
1052097
function p_t(df, t) {
        var c2, s, p, i;

        c2 = df / (df + t * t);
        s = Math.sqrt(1.0 - c2);

        if (t < 0.0) { s = -s; }

        p = 0.0;
        i = df % 2 + 2;
        while (i <= df) {
            p = p + s;
            s = s * ((i - 1) * c2 / i);
            i = i + 2;
        }

        if ((df & 1) !== 0) {
            return 0.5 + (p * Math.sqrt(c2) + Math.atan(t / Math.sqrt(df))) / Math.PI;
        }

        return (1.0 + p) / 2.0;
    }
454187
def _dtfromtimestamp(timestamp):
    
    try:
        return datetime.datetime.fromtimestamp(timestamp)
    except OSError:
        timestamp -= time.timezone
        dt = datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=timestamp)
        if _isdst(dt):
            timestamp += 3600
            dt = datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=timestamp)
        return dt
625950
def timeticks(tdiff):
    
    if isinstance(tdiff, xarray.DataArray):  # len==1
        tdiff = timedelta(seconds=tdiff.values / np.timedelta64(1, 's'))

    assert isinstance(tdiff, timedelta), 'expecting datetime.timedelta'

    if tdiff > timedelta(hours=2):
        return None, None

    elif tdiff > timedelta(minutes=20):
        return MinuteLocator(byminute=range(0, 60, 5)), MinuteLocator(byminute=range(0, 60, 2))

    elif (timedelta(minutes=10) < tdiff) & (tdiff <= timedelta(minutes=20)):
        return MinuteLocator(byminute=range(0, 60, 2)), MinuteLocator(byminute=range(0, 60, 1))

    elif (timedelta(minutes=5) < tdiff) & (tdiff <= timedelta(minutes=10)):
        return MinuteLocator(byminute=range(0, 60, 1)), SecondLocator(bysecond=range(0, 60, 30))

    elif (timedelta(minutes=1) < tdiff) & (tdiff <= timedelta(minutes=5)):
        return SecondLocator(bysecond=range(0, 60, 30)), SecondLocator(bysecond=range(0, 60, 10))

    elif (timedelta(seconds=30) < tdiff) & (tdiff <= timedelta(minutes=1)):
        return SecondLocator(bysecond=range(0, 60, 10)), SecondLocator(bysecond=range(0, 60, 2))

    else:
        return SecondLocator(bysecond=range(0, 60, 2)),  SecondLocator(bysecond=range(0, 60, 1))
546019
async function calculateTtl (ttl = 0, relative = true) {
  if (ttl === 0) return 0
  if (ttl < 0) throw new Error('ttl must be greater than 0')

  if (relative) {
    const { height } = await this.api.getCurrentKeyBlock()
    return +(height) + ttl
  }
  return ttl
}
1206163
def _total_seconds(t):
    '''
    
    '''
    return sum([
        int(t.days * 86400 + t.seconds),
        int(round(t.microseconds / 1000000.0))
    ])
1221416
def step_size(self, t0, t1=None):
    '''
    
    '''
    tb0 = self.to_bucket( t0 )
    if t1:
      tb1 = self.to_bucket( t1, steps=1 ) # NOTE: "end" of second bucket
    else:
      tb1 = self.to_bucket( t0, steps=1 )

    # Calculate the difference in days, then multiply by simple scalar
    days = (self.from_bucket(tb1, native=True) - self.from_bucket(tb0, native=True)).days
    return days * SIMPLE_TIMES['d']