From 32f40ab9525256f1f7654d54f3307a4e9e1bc7c4 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Wed, 8 Jan 2014 20:42:16 +0000 Subject: refs #1486 added method to detect whether current year is a leap year --- core/Date.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'core/Date.php') diff --git a/core/Date.php b/core/Date.php index 3b21ed186a..063420940c 100644 --- a/core/Date.php +++ b/core/Date.php @@ -289,6 +289,18 @@ class Date return $this->getTimestamp() < $date->getTimestamp(); } + /** + * Returns `true` if the current year is a leap year, false otherwise. + * + * @return bool + */ + public function isLeapYear() + { + $currentYear = date('Y', $this->getTimestamp()); + + return ($currentYear % 400) == 0 || (($currentYear % 4) == 0 && ($currentYear % 100) != 0); + } + /** * Converts this date to the requested string format. See {@link http://php.net/date} * for the list of format strings. -- cgit v1.2.3