Get the farthest date from the instance.

        :type dt1: datetime.datetime
        :type dt2: datetime.datetime
        :type dts: list[datetime.datetime,]

        :rtype: DateTime
557740
def farthest(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 max(dts)[1]
699883
def distance_to_furthest(self, ps: Union["Units", List["Point2"], Set["Point2"]]) -> Union[int, float]:
        
        assert ps
        furthest_distance_squared = -math.inf
        for p2 in ps:
            if not isinstance(p2, Point2):
                p2 = p2.position
            distance = (self[0] - p2[0]) ** 2 + (self[1] - p2[1]) ** 2
            if furthest_distance_squared < distance:
                furthest_distance_squared = distance
        return furthest_distance_squared ** 0.5
371361
def GetDate(self):
    
    normalized_timestamp = self._GetNormalizedTimestamp()
    if normalized_timestamp is None:
      return None, None, None

    number_of_days, _, _, _ = self._GetTimeValues(normalized_timestamp)

    try:
      return self._GetDateValuesWithEpoch(
          number_of_days, self._EPOCH_NORMALIZED_TIME)

    except ValueError:
      return None, None, None
499913
def _first_datetime_from(self):
        
        myFromDt = self._getMyFirstDatetimeFrom()
        localTZ = timezone.get_current_timezone()
        return myFromDt.astimezone(localTZ)
661806
def GetDate(self):
    
    if self._timestamp is None:
      return None, None, None

    try:
      number_of_days, _, _, _ = self._GetTimeValues(self._timestamp)
      return self._GetDateValues(number_of_days, 1970, 1, 1)
    except ValueError:
      return None, None, None
764741
def find_farthest(point, hull):
    ''''''
    d_start = np.sum((point-hull[0,:])**2)
    d_end = np.sum((point-hull[-1,:])**2)
    if d_start > d_end:
        # Go in the forward direction
        i = 1
        inc = 1
        term = hull.shape[0]
        d2_max = d_start
    else:
        # Go in the reverse direction
        i = hull.shape[0]-2
        inc = -1
        term = -1
        d2_max = d_end
    while i != term:
        d2 = np.sum((point - hull[i,:])**2)
        if d2 < d2_max:
            break
        i += inc
        d2_max = d2
    return i-inc
264473
def __get_time_range(self, startDate, endDate):
        
        today = date.today()
        start_date = today - timedelta(days=today.weekday(), weeks=1)
        end_date = start_date + timedelta(days=4)

        startDate = startDate if startDate else str(start_date)
        endDate = endDate if endDate else str(end_date)
        
        return startDate, endDate
1212875
def date_in_range(date1, date2, range):
    """"""
    date_obj1 = convert_date(date1)
    date_obj2 = convert_date(date2)
    return (date_obj2 - date_obj1).days <= range
137637
def daterange(self):
        

        return daterange(
            lower=self.lower,
            upper=self.upper,
            lower_inc=self.lower_inc,
            upper_inc=self.upper_inc)
615901
def _upcoming_datetime_from(self):
        
        nextDt = self.__localAfter(timezone.localtime(), dt.time.max,
                                   excludeCancellations=True,
                                   excludeExtraInfo=True)
        return nextDt
606165
def finite_datetimes(self, finite_start, finite_stop):
        
        date_start = datetime(finite_start.year, finite_start.month, finite_start.day)
        dates = []
        for i in itertools.count():
            t = date_start + timedelta(days=i)
            if t >= finite_stop:
                return dates
            if t >= finite_start:
                dates.append(t)
1219933
def datetimeXPos(self, dtime):
        
        gantt = self.ganttWidget()
        scale = gantt.timescale()
        
        # calculate the distance for a minute
        if scale == gantt.Timescale.Minute:
            dstart = gantt.dateTimeStart()
            secs = dstart.secsTo(dtime)
            return secs
        
        # calculate the distance for an hour
        elif scale == gantt.Timescale.Hour:
           dstart = gantt.dateTimeStart()
           secs = dstart.secsTo(dtime)
           return secs / 2.0
        
        # calculate the distance for a day
        elif scale == gantt.Timescale.Day:
            dstart = QDateTime(gantt.dateStart(), QTime(0, 0, 0))
            secs = dstart.secsTo(dtime)
            return (secs / (60.0 * 2.0))
        
        # calculate the distance off the date only
        else:
            return self.dateXPos(dtime.date())
804375
def mean_date(dt_list):
    
    dt_list_sort = sorted(dt_list)
    dt_list_sort_rel = [dt - dt_list_sort[0] for dt in dt_list_sort]
    avg_timedelta = sum(dt_list_sort_rel, timedelta())/len(dt_list_sort_rel)
    return dt_list_sort[0] + avg_timedelta
219210
public function closest(ChronosInterface $dt1, ChronosInterface $dt2)
    {
        return $this->diffInSeconds($dt1) < $this->diffInSeconds($dt2) ? $dt1 : $dt2;
    }
670942
def end_datetime(self) -> Optional[datetime.datetime]:
        
        if not self.intervals:
            return None
        return max([x.end for x in self.intervals])
86048
def get_closest_dt_padded_idx(dt, dt_list, pad=timedelta(days=30)):
    
    #If pad is in decimal days
    if not isinstance(pad, timedelta):
        pad = timedelta(days=pad)
    from pygeotools.lib import malib
    dt_list = malib.checkma(dt_list, fix=False)
    dt_diff = np.abs(dt - dt_list)
    valid_idx = (dt_diff.data < pad).nonzero()[0]
    return valid_idx
185930
def tgread_date(self):
        
        value = self.read_int()
        if value == 0:
            return None
        else:
            return datetime.fromtimestamp(value, tz=timezone.utc)