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:
authorsimivar <simivar@gmail.com>2018-02-26 13:42:59 +0300
committerStefan Giehl <stefan@piwik.org>2018-02-26 13:42:59 +0300
commit07b654dd2c432394f9e6d135c85c59bf7a992218 (patch)
treec50477c6eb278b81aa620b1c0991f5ab12fe92f2 /core/Date.php
parent698f06b0b927f6b2b728ac65d21c3f9016edfe28 (diff)
Update error message in API/UI if date is before 1992 (#12559) (#12561)
* Update error message in API/UI if date is before 1992 (#12559) * Fix test for dates * Fix test for dates * Move creation of $dateOfFirstWebsite object to if block
Diffstat (limited to 'core/Date.php')
-rw-r--r--core/Date.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/Date.php b/core/Date.php
index c33c0ed188..d7b2053910 100644
--- a/core/Date.php
+++ b/core/Date.php
@@ -41,6 +41,9 @@ class Date
/** The default date time string format. */
const DATE_TIME_FORMAT = 'Y-m-d H:i:s';
+
+ /** Timestamp when first website came online - Tue, 06 Aug 1991 00:00:00 GMT. */
+ const FIRST_WEBSITE_TIMESTAMP = 681436800;
const DATETIME_FORMAT_LONG = DateTimeFormatProvider::DATE_FORMAT_LONG;
const DATETIME_FORMAT_SHORT = DateTimeFormatProvider::DATETIME_FORMAT_SHORT;
@@ -141,11 +144,17 @@ class Date
$date = new Date($dateString);
}
$timestamp = $date->getTimestamp();
- // can't be doing web analytics before the 1st website
- // Tue, 06 Aug 1991 00:00:00 GMT
- if ($timestamp < 681436800) {
- throw self::getInvalidDateFormatException($dateString);
+
+ if ($timestamp < self::FIRST_WEBSITE_TIMESTAMP) {
+ $dateOfFirstWebsite = new self(self::FIRST_WEBSITE_TIMESTAMP);
+ $message = Piwik::translate('General_ExceptionInvalidDateBeforeFirstWebsite', array(
+ $date->toString(),
+ $dateOfFirstWebsite->getLocalized(self::DATE_FORMAT_SHORT),
+ $dateOfFirstWebsite->getTimestamp()
+ ));
+ throw new Exception($message . ": $dateString");
}
+
if (empty($timezone)) {
return $date;
}