返回两个日期之间差距,如果结束日期小于开始日期done为fasle

@param {Date} startDate 开始日期
@param {Date} endDate 结束日期或当期日期
@param {Date} rule 自定义计算规则
@return {Object}
979573
function getDateDiff (startDate, endDate, rules) {
  var startTime, endTime, item, diffTime, rule, len, index
  var result = { done: false, time: 0 }
  startDate = toStringDate(startDate)
  endDate = endDate ? toStringDate(endDate) : new Date()
  if (baseExports.isDate(startDate) && baseExports.isDate(endDate)) {
    startTime = getDateTime(startDate)
    endTime = getDateTime(endDate)
    if (startTime < endTime) {
      diffTime = result.time = endTime - startTime
      rule = rules && rules.length > 0 ? rules : setupDefaults.dateDiffRules
      result.done = true
      for (index = 0, len = rule.length; index < len; index++) {
        item = rule[index]
        if (diffTime >= item[1]) {
          if (index === len - 1) {
            result[item[0]] = diffTime || 0
          } else {
            result[item[0]] = Math.floor(diffTime / item[1])
            diffTime -= result[item[0]] * item[1]
          }
        } else {
          result[item[0]] = 0
        }
      }
    }
  }
  return result
}
632859
protected function processOptimalSubperiods($startDate, $endDate)
    {
        while ($startDate->isEarlier($endDate)
            || $startDate == $endDate) {
            $endOfPeriod = null;

            $month        = new Month($startDate);
            $endOfMonth   = $month->getDateEnd();
            $startOfMonth = $month->getDateStart();

            $year        = new Year($startDate);
            $endOfYear   = $year->getDateEnd();
            $startOfYear = $year->getDateStart();

            if ($startDate == $startOfYear
                && ($endOfYear->isEarlier($endDate)
                    || $endOfYear == $endDate
                    || $endOfYear->isLater($this->today)
                )
                // We don't use the year if
                // the end day is in this year, is before today, and year not finished
                && !($endDate->isEarlier($this->today)
                    && $this->today->toString('Y') == $endOfYear->toString('Y')
                    && $this->today->compareYear($endOfYear) == 0)
            ) {
                $this->addSubperiod($year);
                $endOfPeriod = $endOfYear;
            } elseif ($startDate == $startOfMonth
                && ($endOfMonth->isEarlier($endDate)
                    || $endOfMonth == $endDate
                    || $endOfMonth->isLater($this->today)
                )
                // We don't use the month if
                // the end day is in this month, is before today, and month not finished
                && !($endDate->isEarlier($this->today)
                    && $this->today->toString('Y') == $endOfMonth->toString('Y')
                    && $this->today->compareMonth($endOfMonth) == 0)
            ) {
                $this->addSubperiod($month);
                $endOfPeriod = $endOfMonth;
            } else {
                // From start date,
                //  Process end of week
                $week        = new Week($startDate);
                $startOfWeek = $week->getDateStart();
                $endOfWeek   = $week->getDateEnd();

                $firstDayNextMonth      = $startDate->addPeriod(2, 'month')->setDay(1);
                $useMonthsNextIteration = $firstDayNextMonth->isEarlier($endDate);

                if ($useMonthsNextIteration
                    && $endOfWeek->isLater($endOfMonth)
                ) {
                    $this->fillArraySubPeriods($startDate, $endOfMonth, 'day');
                    $endOfPeriod = $endOfMonth;
                } //   If end of this week is later than end date, we use days
                elseif ($this->isEndOfWeekLaterThanEndDate($endDate, $endOfWeek) &&
                    ($endOfWeek->isEarlier($this->today)
                        || $startOfWeek->toString() != $startDate->toString()
                        || $endDate->isEarlier($this->today))
                ) {
                    $this->fillArraySubPeriods($startDate, $endDate, 'day');
                    break 1;
                } elseif ($startOfWeek->isEarlier($startDate)
                    && $endOfWeek->isEarlier($this->today)
                ) {
                    $this->fillArraySubPeriods($startDate, $endOfWeek, 'day');
                    $endOfPeriod = $endOfWeek;
                } else {
                    $this->addSubperiod($week);
                    $endOfPeriod = $endOfWeek;
                }
            }
            $startDate = $endOfPeriod->addDay(1);
        }
    }
894252
public function during($startDate, $endDate)
    {
        $validationResult = QueryValidator::validateCustomDateRange(
            $startDate,
            $endDate
        );
        if ($validationResult->isFailed()) {
            throw new InvalidArgumentException('The start or end date is' .
                ' invalid. Validation fail reasons: ' .
                $validationResult->getFailReason());
        }

        $this->duringStartDate = $startDate;
        $this->duringEndDate = $endDate;
    }
1275316
function(start, end) {
    var date;
    var res = [];
    for (var key in holidays) {
      date = beginningOfDay(new Date(key));
      // given `start` and `end` Date object are both normalized to beginning of the day
      if (beginningOfDay(start) <= date && date <= beginningOfDay(end)) {
        res.push(holiday(date, holidays[key]));
      }
    }
    return res;
  }
976161
public static List<LocalDate> untilDays(String startDate, String endDate, String pattern) {
        return untilDays(parse(startDate, pattern), parse(endDate, pattern));
    }
592696
function toDate(date, startMonth) {
  date = toDatetime(date, startMonth);
  return date ? new Date(date.getFullYear(), date.getMonth(), date.getDate()) : null;
}
483242
@Override
	public double getDaycount(LocalDate startDate, LocalDate endDate) {
		if(startDate.isAfter(endDate)) {
			return -getDaycount(endDate,startDate);
		}

		int startDateDay 	= startDate.getDayOfMonth();
		int startDateMonth 	= startDate.getMonthValue();
		int startDateYear 	= startDate.getYear();

		int endDateDay 		= endDate.getDayOfMonth();
		int endDateMonth 	= endDate.getMonthValue();
		int endDateYear 	= endDate.getYear();

		if(
				isEndOfMonth &&
				startDate.getMonth() == Month.FEBRUARY &&
				startDate.getDayOfMonth() == startDate.lengthOfMonth() &&
				endDate.getMonth() == Month.FEBRUARY &&
				endDate.getDayOfMonth() == endDate.lengthOfMonth()
				) {
			endDateDay = 30;
		}

		if(
				isEndOfMonth &&
				startDate.getMonth() == Month.FEBRUARY &&
				startDate.getDayOfMonth() == startDate.lengthOfMonth()
				) {
			startDateDay = 30;
		}

		if(endDateDay > 30 && startDateDay >= 30) {
			endDateDay = 30;
		}
		startDateDay = Math.min(startDateDay,30);

		return (endDateYear - startDateYear) * 360.0 + (endDateMonth - startDateMonth) * 30.0 + (endDateDay - startDateDay);
	}
984215
public static long getMinutesDifference(Date startDate, Date endDate) {
		long startTime = startDate.getTime();
		long endTime = endDate.getTime();
		long diffTime = endTime - startTime;
		long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(diffTime);
		return diffInMinutes;
	}
507995
public static long getTwoDaysBetweenNumber(String startDate, String endDate, Format format) {
        SimpleDateFormat localFormat = (SimpleDateFormat) format;
        long day = 0;
        try {
            java.util.Date startDay = localFormat.parse(startDate);
            java.util.Date endDay = localFormat.parse(endDate);
            day = (endDay.getTime() - startDay.getTime()) / (24 * 60 * 60 * 1000);
        } catch (Exception e) {
            return 0;
        }
        return day;
    }
258805
public static long getDaysBetweenIgnoreTime(String startDate, String endDate, Format format) {
        SimpleDateFormat localFormat = (SimpleDateFormat) format;
        try {
            java.util.Date startDay = localFormat.parse(startDate);
            java.util.Date endDay = localFormat.parse(endDate);
            return getDaysBetweenIgnoreTime(startDay, endDay);
        } catch (Exception e) {
            return 0;
        }
    }
1307403
protected function areWeInRange($startDate, $endDate){
        return (empty($startDate) || date_create() >= $startDate)
        && (empty($endDate) || date_create() <= $endDate);
    }
899368
public static long getMillisDifference(Date startDate, Date endDate) {
		long startTime = startDate.getTime();
		long endTime = endDate.getTime();
		long diffTime = endTime - startTime;
		return diffTime;
	}
286319
public Interval withDates(LocalDate startDate, LocalDate endDate) {
        requireNonNull(startDate);
        requireNonNull(endDate);
        return new Interval(startDate, this.startTime, endDate, this.endTime, this.zoneId);
    }
869951
public static int datedif(EvaluationContext ctx, Object startDate, Object endDate, Object unit) {
        LocalDate _startDate = Conversions.toDate(startDate, ctx);
        LocalDate _endDate = Conversions.toDate(endDate, ctx);
        String _unit = Conversions.toString(unit, ctx).toLowerCase();

        if (_startDate.isAfter(_endDate)) {
            throw new RuntimeException("Start date cannot be after end date");
        }

        switch (_unit) {
        case "y":
            return (int) ChronoUnit.YEARS.between(_startDate, _endDate);
        case "m":
            return (int) ChronoUnit.MONTHS.between(_startDate, _endDate);
        case "d":
            return (int) ChronoUnit.DAYS.between(_startDate, _endDate);
        case "md":
            return Period.between(_startDate, _endDate).getDays();
        case "ym":
            return Period.between(_startDate, _endDate).getMonths();
        case "yd":
            return (int) ChronoUnit.DAYS.between(_startDate.withYear(_endDate.getYear()), _endDate);
        }

        throw new RuntimeException("Invalid unit value: " + _unit);
    }
1001046
function CronDate (date) {
		this.milliseconds = date.getMilliseconds();
		this.seconds = date.getSeconds() + 1;
		this.minutes = date.getMinutes();
		this.hours = date.getHours();
		this.days = date.getDate();
		this.months  = date.getMonth();
		this.years = date.getFullYear();
	}
893912
public boolean isIn(Date beginDate, Date endDate) {
		long beginMills = beginDate.getTime();
		long endMills = endDate.getTime();
		long thisMills = this.getTime();

		return thisMills >= Math.min(beginMills, endMills) && thisMills <= Math.max(beginMills, endMills);
	}
212197
function(date) {
        var start = this.findMonthStart(date);
        var nextMonth = this.add(start, this.MONTH, 1);
        var end = this.subtract(nextMonth, this.DAY, 1);
        return end;
    }