/** * DateDiffCalculator that calculates diff to the past in one of the units: * - seconds * - minutes * - "yesterday" * - hours * - days * - weeks (up to 14 days) * - full date * * @return DateDiffCalculator */ 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()]); }); }
protected function createRule() { return Rules::daysAgo(); }