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:
Diffstat (limited to 'core/Period/Factory.php')
-rw-r--r--core/Period/Factory.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/Period/Factory.php b/core/Period/Factory.php
index 1f4afabbc2..4fac7eba51 100644
--- a/core/Period/Factory.php
+++ b/core/Period/Factory.php
@@ -74,6 +74,7 @@ abstract class Factory
self::checkPeriodIsEnabled($period);
if (is_string($date)) {
+ list($period, $date) = self::convertRangeToDateIfNeeded($period, $date);
if (Period::isMultiplePeriod($date, $period)
|| $period == 'range'
) {
@@ -130,6 +131,19 @@ abstract class Factory
throw new Exception($message);
}
+ private static function convertRangeToDateIfNeeded($period, $date)
+ {
+ if (is_string($period) && is_string($date) && $period === 'range') {
+ $dates = explode(',', $date);
+ if (count($dates) === 2 && $dates[0] === $dates[1]) {
+ $period = 'day';
+ $date = $dates[0];
+ }
+ }
+
+ return array($period, $date);
+ }
+
/**
* Creates a Period instance using a period, date and timezone.
*
@@ -146,6 +160,8 @@ abstract class Factory
$timezone = 'UTC';
}
+ list($period, $date) = self::convertRangeToDateIfNeeded($period, $date);
+
if ($period == 'range') {
self::checkPeriodIsEnabled('range');
$oPeriod = new Range('range', $date, $timezone, Date::factory('today', $timezone));