diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2010-07-27 04:19:04 +0400 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2010-07-27 04:19:04 +0400 |
commit | 5a9353b2d991b4a11c1b7d5b222993e94731d5f7 (patch) | |
tree | 733b9e21bd2e62968109b2bf8aa344b774442283 /core/Date.php | |
parent | 5982e16d2541861cf7c487016c1a5afa38d0415d (diff) |
Refs #1486
Patch by halfdan required by Alerts plugin
* Invert pattern match
* Date.addPeriod and Date.subPeriod
git-svn-id: http://dev.piwik.org/svn/trunk@2701 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'core/Date.php')
-rw-r--r-- | core/Date.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/Date.php b/core/Date.php index 45bd29d1a6..5390357293 100644 --- a/core/Date.php +++ b/core/Date.php @@ -546,7 +546,25 @@ class Piwik_Date */ public function addPeriod( $n, $period ) { + if($n < 0) { + $ts = strtotime("$n $period", $this->timestamp); + } + else { $ts = strtotime("+$n $period", $this->timestamp); + } return new Piwik_Date( $ts, $this->timezone ); } + + /** + * Subtracts period from the existing date object. + * Returned is the new date object + * Doesn't modify $this + * + * @param int Number of period to sub + * @return Piwik_Date new date + */ + public function subPeriod( $n, $period ) + { + return $this->addPeriod(-$n, $period ); +} } |