diff options
Diffstat (limited to 'core/Period.php')
-rw-r--r-- | core/Period.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/Period.php b/core/Period.php index 6e3ef0f327..e717995f28 100644 --- a/core/Period.php +++ b/core/Period.php @@ -248,6 +248,21 @@ abstract class Period } /** + * Returns whether the date `$date` is within the current period or not. + * + * Note: the time component of the period's dates and `$date` is ignored. + * + * @param Date $today + * @return bool + */ + public function isDateInPeriod(Date $date) + { + $ts = $date->getStartOfDay()->getTimestamp(); + return $ts >= $this->getDateStart()->getStartOfDay()->getTimestamp() + && $ts < $this->getDateEnd()->addDay(1)->getStartOfDay()->getTimestamp(); + } + + /** * Add a date to the period. * * Protected because adding periods after initialization is not supported. |