diff --git a/framework/core/src/Core/Search/Discussion/Gambit/CreatedGambit.php b/framework/core/src/Core/Search/Discussion/Gambit/CreatedGambit.php index 3696d180e..65cfe0513 100644 --- a/framework/core/src/Core/Search/Discussion/Gambit/CreatedGambit.php +++ b/framework/core/src/Core/Search/Discussion/Gambit/CreatedGambit.php @@ -18,8 +18,6 @@ use LogicException; class CreatedGambit extends AbstractRegexGambit { /** - * http://stackoverflow.com/a/8270148/3158312 - * * {@inheritdoc} */ protected $pattern = 'created:(\d{4}\-\d\d\-\d\d)(\.\.(\d{4}\-\d\d\-\d\d))?'; @@ -33,10 +31,14 @@ class CreatedGambit extends AbstractRegexGambit throw new LogicException('This gambit can only be applied on a DiscussionSearch'); } - if (empty($matches[4])) { // Single date - $search->getQuery()->whereDate('start_time', $negate ? '!=' : '=', $matches[2]); - } else { // Range: date..date - $search->getQuery()->whereBetween('start_time', [$matches[2], $matches[4]], 'and', $negate); + // If we've just been provided with a single YYYY-MM-DD date, then find + // discussions that were started on that exact date. But if we've been + // provided with a YYYY-MM-DD..YYYY-MM-DD range, then find discussions + // that were started during that period. + if (empty($matches[3])) { + $search->getQuery()->whereDate('start_time', $negate ? '!=' : '=', $matches[1]); + } else { + $search->getQuery()->whereBetween('start_time', [$matches[1], $matches[3]], 'and', $negate); } } }