|
|
@@ -467,6 +467,32 @@ class CakeTime {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Returns true if given datetime string is in the future.
|
|
|
+ *
|
|
|
+ * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
|
|
|
+ * @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
|
|
|
+ * @return boolean True if datetime string is in the future
|
|
|
+ * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
|
|
+ */
|
|
|
+ public static function isFuture($dateString, $timezone = null) {
|
|
|
+ $timestamp = self::fromString($dateString, $timezone);
|
|
|
+ return $timestamp > time();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Returns true if given datetime string is in the past.
|
|
|
+ *
|
|
|
+ * @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
|
|
|
+ * @param string|DateTimeZone $timezone Timezone string or DateTimeZone object
|
|
|
+ * @return boolean True if datetime string is in the past
|
|
|
+ * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#testing-time
|
|
|
+ */
|
|
|
+ public static function isPast($dateString, $timezone = null) {
|
|
|
+ $timestamp = self::fromString($dateString, $timezone);
|
|
|
+ return $timestamp < time();
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Returns true if given datetime string is within this week.
|
|
|
*
|
|
|
* @param integer|string|DateTime $dateString UNIX timestamp, strtotime() valid string or DateTime object
|