Reduces a timespan with multiple begin or end dates to a single earliest
 begin date and a single latest end date.

 @param timespan [DPLA::MAP::TimeSpan] the timespan to reduce

 @return [DPLA::MAP::TimeSpan] an updated timespan
9656
def reduce_to_largest_span(timespan)
      timespan.begin = timespan.begin.sort.first
      timespan.end = timespan.end.sort.last
      timespan
    end
127446
public static Date beginOfDate(@NotNull final Date date) {
		return DateUtils.truncate(date, Calendar.DATE);
	}
184670
@Override
    public long until(Temporal endExclusive, TemporalUnit unit) {
        @SuppressWarnings("unchecked")
        ChronoLocalDateTime<D> end = (ChronoLocalDateTime<D>) toLocalDate().getChronology().localDateTime(endExclusive);
        if (unit instanceof ChronoUnit) {
            ChronoUnit f = (ChronoUnit) unit;
            if (f.isTimeBased()) {
                long amount = end.getLong(EPOCH_DAY) - date.getLong(EPOCH_DAY);
                switch (f) {
                    case NANOS: amount = Jdk8Methods.safeMultiply(amount, NANOS_PER_DAY); break;
                    case MICROS: amount = Jdk8Methods.safeMultiply(amount, MICROS_PER_DAY); break;
                    case MILLIS: amount = Jdk8Methods.safeMultiply(amount, MILLIS_PER_DAY); break;
                    case SECONDS: amount = Jdk8Methods.safeMultiply(amount, SECONDS_PER_DAY); break;
                    case MINUTES: amount = Jdk8Methods.safeMultiply(amount, MINUTES_PER_DAY); break;
                    case HOURS: amount = Jdk8Methods.safeMultiply(amount, HOURS_PER_DAY); break;
                    case HALF_DAYS: amount = Jdk8Methods.safeMultiply(amount, 2); break;
                }
                return Jdk8Methods.safeAdd(amount, time.until(end.toLocalTime(), unit));
            }
            ChronoLocalDate endDate = end.toLocalDate();
            if (end.toLocalTime().isBefore(time)) {
                endDate = endDate.minus(1, ChronoUnit.DAYS);
            }
            return date.until(endDate, unit);
        }
        return unit.between(this, end);
    }
1014497
private void splitDays(ProjectCalendar calendar, LinkedList<TimephasedWork> list)
   {
      LinkedList<TimephasedWork> result = new LinkedList<TimephasedWork>();
      for (TimephasedWork assignment : list)
      {
         while (assignment != null)
         {
            Date startDay = DateHelper.getDayStartDate(assignment.getStart());
            Date finishDay = DateHelper.getDayStartDate(assignment.getFinish());

            // special case - when the finishday time is midnight, it's really the previous day...
            if (assignment.getFinish().getTime() == finishDay.getTime())
            {
               finishDay = DateHelper.addDays(finishDay, -1);
            }

            if (startDay.getTime() == finishDay.getTime())
            {
               result.add(assignment);
               break;
            }

            TimephasedWork[] split = splitFirstDay(calendar, assignment);
            if (split[0] != null)
            {
               result.add(split[0]);
            }
            assignment = split[1];
         }
      }

      list.clear();
      list.addAll(result);
   }
372735
public Period setEnd( Date theDate,  TemporalPrecisionEnum thePrecision) {
    end = new DateTimeType(theDate, thePrecision); 
    return this; 
  }
546021
def as_dates(self):
        
        new_start = self.start.date() if self.start and isinstance(self.start, datetime.datetime) else self.start
        new_end = self.end.date() if self.end and isinstance(self.end, datetime.datetime) else self.end
        return DateRange(new_start, new_end, CLOSED_CLOSED)
225609
def timeslot_options(
    interval=swingtime_settings.TIMESLOT_INTERVAL,
    start_time=swingtime_settings.TIMESLOT_START_TIME,
    end_delta=swingtime_settings.TIMESLOT_END_TIME_DURATION,
    fmt=swingtime_settings.TIMESLOT_TIME_FORMAT
):
    '''
    

    '''
    dt = datetime.combine(date.today(), time(0))
    dtstart = datetime.combine(dt.date(), start_time)
    dtend = dtstart + end_delta
    options = []

    while dtstart <= dtend:
        options.append((str(dtstart.time()), dtstart.strftime(fmt)))
        dtstart += interval

    return options
1090270
public int nextSpanTransition(int start, int limit, Class kind) {
        int count = mSpanCount;
        Object[] spans = mSpans;
        int[] starts = mSpanStarts;
        int[] ends = mSpanEnds;
        int gapstart = mGapStart;
        int gaplen = mGapLength;

        if (kind == null) {
            kind = Object.class;
        }

        for (int i = 0; i < count; i++) {
            int st = starts[i];
            int en = ends[i];

            if (st > gapstart)
                st -= gaplen;
            if (en > gapstart)
                en -= gaplen;

            if (st > start && st < limit && kind.isInstance(spans[i]))
                limit = st;
            if (en > start && en < limit && kind.isInstance(spans[i]))
                limit = en;
        }

        return limit;
    }
1227963
private long getTime(Date start, Date end)
   {
      long total = 0;
      if (start != null && end != null)
      {
         Date startTime = DateHelper.getCanonicalTime(start);
         Date endTime = DateHelper.getCanonicalTime(end);

         Date startDay = DateHelper.getDayStartDate(start);
         Date finishDay = DateHelper.getDayStartDate(end);

         //
         // Handle the case where the end of the range is at midnight -
         // this will show up as the start and end days not matching
         //
         if (startDay.getTime() != finishDay.getTime())
         {            
            endTime = DateHelper.addDays(endTime, 1);
         }

         total = (endTime.getTime() - startTime.getTime());
      }
      return (total);
   }
1012983
public static Collection<TimeSlot> calculateAvailableSots(Collection<TimeInterval> takenTimeSlots, Date date, int intervalSeconds,Time startTime, Time endTime)
   {
      Day day = new Day(date);
      
      Collection<TimeSlot> allTimeSlots = calculateTimeSots(day,intervalSeconds,startTime, endTime);
      
      if(takenTimeSlots == null || takenTimeSlots.isEmpty())
         return allTimeSlots;
      
      TimeSlot timeSlot = null;
      TreeSet<TimeSlot> availableSlots = new TreeSet<TimeSlot>();
      for (Iterator<TimeSlot> i = allTimeSlots.iterator(); i.hasNext();)
      {
         timeSlot =  i.next();
         
         if(!takenTimeSlots.contains(timeSlot))
         {
            availableSlots.add(timeSlot);
         }         
      }
      return availableSlots;
   }
442157
def cut(self, times: Union[datetime.datetime,
                               List[datetime.datetime]]) -> List["Interval"]:
        
        if not isinstance(times, list):
            # Single time
            time = times
            if not self.contains(time):
                return []
            return [
                Interval(self.start, time),
                Interval(time, self.end)
            ]
        else:
            # Multiple times
            times = [t for t in times if self.contains(t)]  # discard others
            times.sort()
            times = [self.start] + times + [self.end]
            intervals = []
            for i in range(len(times) - 1):
                intervals.append(Interval(times[i], times[i + 1]))
            return intervals
625756
public Date getThere(Date start, Distance distance)
    {
        TimeSpan timeSpan = getTimeSpan(distance);
        return timeSpan.addDate(start);
    }
1362928
private boolean isOK(TimeSpan timeSpan) {
	return res.exists() && (res.lastModified() + timeSpan.getMillis() >= System.currentTimeMillis());
    }
206977
@Override
    ChronoInterval<PlainDate> newInterval(
        Boundary<PlainDate> start,
        Boundary<PlainDate> end
    ) {

        return DateIntervalFactory.INSTANCE.between(start, end);

    }
564671
def timespan(start_time):
    """"""

    timespan = datetime.datetime.now() - start_time
    timespan_ms = timespan.total_seconds() * 1000
    return timespan_ms
124810
public function difference(DateTimeSpan $dtsSpan)
    {
        $intDifference = $this->Seconds - $dtsSpan->Seconds;
        $dtsDateSpan = new DateTimeSpan();
        $dtsDateSpan->addSeconds($intDifference);
        return $dtsDateSpan;
    }
1097481
function(startDate, endDate) {
    var current = new Date(startDate);
    var end = new Date(endDate); 
    var dates = [];

    while(current <= end) {

        var m = current.getMonth() + 1;
        var d = current.getDate();
        var oneDate = [
            current.getFullYear(),
            m < 10 ? "0" + m : m,
            d < 10 ? "0" + d : d].join('-');

        dates.push(oneDate);
        current.setDate(current.getDate() + 1);
    }

    return dates;
}