Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Date.php6
-rw-r--r--tests/core/Date.test.php5
2 files changed, 10 insertions, 1 deletions
diff --git a/core/Date.php b/core/Date.php
index 43e6a4e707..3c7962ce1e 100644
--- a/core/Date.php
+++ b/core/Date.php
@@ -79,7 +79,7 @@ class Piwik_Date
{
$date = new Piwik_Date($dateString);
}
- if(is_null($timezone))
+ if(empty($timezone))
{
return $date;
}
@@ -205,6 +205,10 @@ class Piwik_Date
*/
public function getTimestamp()
{
+ if(empty($this->timezone))
+ {
+ $this->timezone = 'UTC';
+ }
$utcOffset = self::extractUtcOffset($this->timezone);
if($utcOffset !== false) {
return (int)($this->timestamp - $utcOffset * 3600);
diff --git a/tests/core/Date.test.php b/tests/core/Date.test.php
index e80846d4ec..09a165370a 100644
--- a/tests/core/Date.test.php
+++ b/tests/core/Date.test.php
@@ -82,6 +82,11 @@ class Test_Piwik_Date extends UnitTestCase
$this->assertEqual($date->getDateStartUTC(), $dayStart);
$this->assertEqual($date->getDateEndUTC(), $dayEnd);
+ // try with empty timezone
+ $date = $date->setTimezone('');
+ $this->assertEqual($date->getDateStartUTC(), $dayStart);
+ $this->assertEqual($date->getDateEndUTC(), $dayEnd);
+
$date = $date->setTimezone('UTC');
$this->assertEqual($date->getDateStartUTC(), $dayStart);
$this->assertEqual($date->getDateEndUTC(), $dayEnd);