Get the differnces between two dates in weeks
@param $date1 First date
@param $date2 Second date
@param $which_connection see method close()
@return The SQL expression

This method currently only supports MySQL and MSSQL
508590
public function weekdiff($date1,$date2,$which_connection='')
    {
        $which_connection = $which_connection === '' ? $this->default_db : $which_connection;
        $adapter = $this->getAdapter($this->connectionType($which_connection));
        return $adapter->weekdiff($date1, $date2);
    }
1165670
public static function dateDiff($from, $to = null)
    {
        if (!$to) {
            $to = $from;
            $from = date("d/m/Y");
        }

        if (!$dateFrom = static::date("U", $from)) {
            return;
        }

        if (!$dateTo = static::date("U", $to)) {
            return;
        }

        $diff = $dateTo - $dateFrom;
        $days = round($diff / 86400);

        return $days;
    }
107875
public function sep($which_connection='')
    {
        $which_connection = $which_connection === '' ? $this->default_db : $which_connection;
        $adapter = $this->getAdapter($this->connectionType($which_connection));
        if ($adapter == null) {
            return '.';
        }
        return $adapter->sep();
    }
704980
public function diffInWeeks(Date $dt = null, $abs = true)
    {
        return (int) ($this->diffInDays($dt, $abs) / static::DAYS_PER_WEEK);
    }
637915
static public function daysBetweenDates(string $date1, string $date2):? int
    {
        // If input dates have datetime 'Y-m-d X' format, take only the date part
        list($d1) = array_pad(explode(' ', $date1), 1, 0);
        list($d2) = array_pad(explode(' ', $date2), 1, 0);

        if (!self::checkDate($d1) || !self::checkDate($d2)) {
            return null;
        }

        if (!($dates = self::splitDates($d1, $d2))) {
            return null;
        }

        return (count($dates) - 1);
    }
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
821274
public static function upTo2Weeks()
    {
        return self::getOrCreate('up-to-2-weeks', function () {
            return new DateDiffCalculator([
                RangeRule::createForNegativeValues(2 * DateUnits::WEEK, INF, function (DateDiffRequest $request) {
                    return DateDiffResult::createFullDate($request);
                }),
                Rules::weeksAgo(),
                Rules::yesterday(),
                Rules::daysAgo(),
                Rules::hoursAgo(),
                Rules::minutesAgo(),
                Rules::secondsAgo()
            ]);
        });
    }
170402
public function orWhereColumn($first, $operator = null, $second = null)
    {
        return $this->whereColumn($first, $operator, $second, 'or');
    }
600541
public function get(DateTime $date, DateTime $reference_date = null )
    {
        if (is_null($reference_date)) {
            $reference_date = new DateTime();
        }
        
        $diff = $reference_date->diff($date);
        return $this->getText($diff, $date);
    }
605859
public static Weeks between(CalendarWeek w1, CalendarWeek w2) {

        PlainDate d1 = w1.at(Weekday.MONDAY);
        PlainDate d2 = w2.at(Weekday.MONDAY);
        return Weeks.between(d1, d2);

    }
22931
public static function compare($date1, $date2): int
    {
        $d1 = static::create($date1);
        $d2 = static::create($date2);

        return ($d1 > $d2) ? static::DATETIME_GREATER : (($d1 < $d2) ? static::DATETIME_LESS : static::DATETIME_EQUAL);
    }
875670
public function isBetween(Date $dt1, Date $dt2, $equal = true)
    {
        if ($dt1->isAfter($dt2)) {
            $temp = $dt1;
            $dt1 = $dt2;
            $dt2 = $temp;
        }

        if ($equal) {
            return $this->isAfterOrEquals($dt1) && $this->isBeforeOrEquals($dt2);
        }

        return $this->isAfter($dt1) && $this->isBefore($dt2);
    }
722066
def business_days_between(date1, date2)
      date1, date2 = date1.to_date, date2.to_date

      # To optimise this method we split the range into full weeks and a
      # remaining period.
      #
      # We then calculate business days in the full weeks period by
      # multiplying number of weeks by number of working days in a week and
      # removing holidays one by one.

      # For the remaining period, we just loop through each day and check
      # whether it is a business day.

      # Calculate number of full weeks and remaining days
      num_full_weeks, remaining_days = (date2 - date1).to_i.divmod(7)

      # First estimate for full week range based on # biz days in a week
      num_biz_days = num_full_weeks * working_days.length

      full_weeks_range = (date1...(date2 - remaining_days))
      num_biz_days -= holidays.count do |holiday|
        in_range = full_weeks_range.cover?(holiday)
        # Only pick a holiday if its on a working day (e.g., not a weekend)
        on_biz_day = working_days.include?(holiday.strftime('%a').downcase)
        in_range && on_biz_day
      end

      remaining_range = (date2-remaining_days...date2)
      # Loop through each day in remaining_range and count if a business day
      num_biz_days + remaining_range.count { |a| business_day?(a) }
    end
250190
public static function compare($date1, $date2, $operator = null)
    {
        $date1 = $date1 instanceof \DateTimeInterface ? $date1 : new \DateTime($date1);
        $date2 = $date2 instanceof \DateTimeInterface ? $date2 : new \DateTime($date2);

        if ($operator === null) {
            if ($date1 == $date2) {
                return 0;
            }

            return (int) ($date1 < $date2);
        }

        switch ((string) $operator) {
            case '=':
                return $date1 == $date2;
            case '!=':
                return $date1 != $date2;
            case '>':
            case 'gt':
                return $date1 > $date2;
            case '>=':
            case 'gte':
                return $date1 >= $date2;
            case '<':
            case 'lt':
                return $date1 < $date2;
            case '<=':
            case 'lte':
                return $date1 <= $date2;
        }

        throw new \InvalidArgumentException('Invalid operator: ' . $operator);
    }
1067524
public static boolean isSameWeek(final Date date1, final Date date2) {
        final Calendar cal1 = Calendar.getInstance();
        cal1.setFirstDayOfWeek(Calendar.MONDAY);
        cal1.setTime(date1);

        final Calendar cal2 = Calendar.getInstance();
        cal2.setFirstDayOfWeek(Calendar.MONDAY);
        cal2.setTime(date2);

        return cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA)
                && cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)
                && cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR);
    }
714352
public function dayofweek($field,$which_connection='')
    {
        $which_connection = $which_connection === '' ? $this->default_db : $which_connection;
        $adapter = $this->getAdapter($this->connectionType($which_connection));
        return $adapter->dayofweek($field);
    }
1353164
public static function between($date, $date1, $date2) : bool {
		$date = strtotime($date);
		return ($date >= strtotime($date1) && $date <= strtotime($date2));
	}