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:
authorMatthieu Napoli <matthieu@mnapoli.fr>2015-01-09 02:44:23 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-01-09 04:35:15 +0300
commit6760edef5a03a2b347d401e1886bbe7c39bf1366 (patch)
tree67ef9d743a50cee2f17253ccb1d8345e4072ed8f /core/Date.php
parent39c0ef2cf1a13a272271b5743561876ea41259d4 (diff)
Reduced possibly useless calls to translate: -1800 calls in my test with Visitor Log, saving 400ms
Diffstat (limited to 'core/Date.php')
-rw-r--r--core/Date.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/Date.php b/core/Date.php
index 26f07a7ac1..4d89d2c7bf 100644
--- a/core/Date.php
+++ b/core/Date.php
@@ -105,7 +105,6 @@ class Date
*/
public static function factory($dateString, $timezone = null)
{
- $invalidDateException = new Exception(Piwik::translate('General_ExceptionInvalidDateFormat', array("YYYY-MM-DD, or 'today' or 'yesterday'", "strtotime", "http://php.net/strtotime")) . ": $dateString");
if ($dateString instanceof self) {
$dateString = $dateString->toString();
}
@@ -126,7 +125,7 @@ class Date
($dateString = strtotime($dateString)) === false
)
) {
- throw $invalidDateException;
+ throw self::getInvalidDateFormatException($dateString);
} else {
$date = new Date($dateString);
}
@@ -134,7 +133,7 @@ class Date
// can't be doing web analytics before the 1st website
// Tue, 06 Aug 1991 00:00:00 GMT
if ($timestamp < 681436800) {
- throw $invalidDateException;
+ throw self::getInvalidDateFormatException($dateString);
}
if (empty($timezone)) {
return $date;
@@ -764,4 +763,10 @@ class Date
{
return $secs / self::NUM_SECONDS_IN_DAY;
}
+
+ private static function getInvalidDateFormatException($dateString)
+ {
+ $message = Piwik::translate('General_ExceptionInvalidDateFormat', array("YYYY-MM-DD, or 'today' or 'yesterday'", "strtotime", "http://php.net/strtotime"));
+ return new Exception($message . ": $dateString");
+ }
}