diff --git a/lib/Parser/MimeDir.php b/lib/Parser/MimeDir.php index 26a7101e5..257fcdc05 100644 --- a/lib/Parser/MimeDir.php +++ b/lib/Parser/MimeDir.php @@ -2,6 +2,7 @@ namespace Sabre\VObject\Parser; +use DateTimeInterface; use Sabre\VObject\Component; use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VCard; @@ -39,6 +40,20 @@ class MimeDir extends Parser */ protected $root; + /** + * Start of range. + * + * @var DateTimeInterface|null + */ + protected $start; + + /** + * End of range. + * + * @var DateTimeInterface|null + */ + protected $end; + /** * By default all input will be assumed to be UTF-8. * @@ -136,6 +151,20 @@ public function setInput($input) } } + /** + * Sets the time range. + * + * Any VEvent object falling outside of this time range will be ignored. + * + * @param DateTimeInterface $start + * @param DateTimeInterface $end + */ + public function setTimeRange(DateTimeInterface $start = null, DateTimeInterface $end = null) + { + $this->start = $start; + $this->end = $end; + } + /** * Parses an entire document. */ @@ -173,6 +202,13 @@ protected function parseDocument() } $result = $this->parseLine($line); if ($result) { + if ($result instanceof Component\VEvent) { + if ($this->start && $this->end) { + if (!$result->isInTimeRange($this->start, $this->end)) { + continue; + } + } + } $this->root->add($result); } }