private static function matchesDateCriteria($key, RateInterface $rate, array $criteria)
    {
        $date = self::extractDateCriteria($key, $criteria);

        if ($date === null) {
            return true;
        }

        if ($key === 'dateFrom') {
            $rateDate = new \DateTime($rate->getDate()->format(\DateTime::ATOM));
            $rateDate->setTime(23, 59, 59);
            return $date <= $rateDate;
        }

        if ($key === 'dateTo') {
            $rateDate = new \DateTime($rate->getDate()->format(\DateTime::ATOM));
            $rateDate->setTime(0, 0, 0);
            return $date >= $rateDate;
        }

        return $date->format('Y-m-d') === $rate->getDate()->format('Y-m-d');
    }