Provide the last and next leap-second events relative to a date

        Args:
            date (float): Date in MJD
        Return:
            tuple:
8282
def get_last_next(self, date):
        
        past, future = (None, None), (None, None)

        for mjd, value in reversed(self.data):
            if mjd <= date:
                past = (mjd, value)
                break
            future = (mjd, value)

        return past, future
1107531
def QA_util_get_real_date(date, trade_list=trade_date_sse, towards=-1):
    
    date = str(date)[0:10]
    if towards == 1:
        while date not in trade_list:
            date = str(
                datetime.datetime.strptime(str(date)[0:10],
                                           '%Y-%m-%d') +
                datetime.timedelta(days=1)
            )[0:10]
        else:
            return str(date)[0:10]
    elif towards == -1:
        while date not in trade_list:
            date = str(
                datetime.datetime.strptime(str(date)[0:10],
                                           '%Y-%m-%d') -
                datetime.timedelta(days=1)
            )[0:10]
        else:
            return str(date)[0:10]
723449
def date_range(start_date, end_date, increment, period):
    
    next = start_date
    delta = relativedelta.relativedelta(**{period:increment})
    while next <= end_date:
        yield next
        next += delta
850535
def last_day(date):
    
    sc = SparkContext._active_spark_context
    return Column(sc._jvm.functions.last_day(_to_java_column(date)))
752966
def _parse_date_input(date_input, default_offset=0):
    """"""
    if date_input:
        try:
            return parse_date_input(date_input)
        except ValueError as err:
            raise CommandError(force_text(err))
    else:
        return get_midnight() - timedelta(days=default_offset)
972767
def get_seconds_until_next_day(now=None):
    
    if now is None:
        now = arrow.utcnow()
    return (now.ceil('day') - now).seconds
281178
def component_on_date(self, date: datetime.date) -> Optional["Interval"]:
        
        return self.intersection(Interval.wholeday(date))
610822
def date(value):
    
    if isinstance(value, str):
        value = to_date(value)
    return literal(value, type=dt.date)
636536
def nextStation(ID, date):
    
    jd = eph.nextStation(ID, date.jd)
    return Datetime.fromJD(jd, date.utcoffset)
744613
def short_timesince(date):
    
    try:
        t = timesince(date).split(", ")[0]
    except IndexError:
        t = timesince(date)
    return t
1170658
function(d) {
    return d.wmStart || (d.wmStart = later.date.next(
      later.Y.val(d),
      later.M.val(d),
      Math.max(later.D.val(d) - later.dw.val(d) + 1, 1)));
  }
1203908
def date_cast(date):
    '''
    
    '''
    if date is None:
        return datetime.datetime.now()
    elif isinstance(date, datetime.datetime):
        return date

    # fuzzy date
    try:
        if isinstance(date, six.string_types):
            try:
                if HAS_TIMELIB:
                    # py3: yes, timelib.strtodatetime wants bytes, not str :/
                    return timelib.strtodatetime(
                        salt.utils.stringutils.to_bytes(date))
            except ValueError:
                pass

            # not parsed yet, obviously a timestamp?
            if date.isdigit():
                date = int(date)
            else:
                date = float(date)

        return datetime.datetime.fromtimestamp(date)
    except Exception:
        if HAS_TIMELIB:
            raise ValueError('Unable to parse {0}'.format(date))

        raise RuntimeError(
                'Unable to parse {0}. Consider installing timelib'.format(date))
1148637
def nextSolarEclipse(date):
    

    eclipse = swe.solarEclipseGlobal(date.jd, backward=False)
    return Datetime.fromJD(eclipse['maximum'], date.utcoffset)
635521
def timespan(self, from_date, to_date=None, span=None, current=False):
        
        if span and not to_date:
            diff = None
            if span == 'month':
                diff = relativedelta(months=1)
            elif span == 'week':
                diff = relativedelta(days=7)
            elif span == 'day':
                diff = relativedelta(days=1)
            if diff is not None:
                to_date = from_date + diff
        datesQ = Q(end_time__gte=from_date)
        datesQ &= Q(end_time__lt=to_date) if to_date else Q()
        datesQ |= Q(end_time__isnull=True) if current else Q()
        return self.filter(datesQ)
373222
def date_to_datetime(date, fraction=0.0):
    
    day_seconds = (60 * 60 * 24) - 1
    total_seconds = int(day_seconds * fraction)
    delta = datetime.timedelta(seconds=total_seconds)
    time = datetime.time()
    dt = datetime.datetime.combine(date, time) + delta
    return dt
596804
def index(self, date):
        
        for (i, (start, end, ruler)) in enumerate(self.table):
            if start <= date.jd <= end:
                return i
        return None
120838
def dategenerator(start, end, step=1, desc=False):
    ''''''
    delta = timedelta(abs(step))
    end = max(start, end)
    if desc:
        dt = end
        while dt >= start:
            yield dt
            dt -= delta
    else:
        dt = start
        while dt <= end:
            yield dt
            dt += delta