diff options
author | Stefan Giehl <stefan@piwik.org> | 2018-08-28 04:25:00 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2018-08-28 04:25:00 +0300 |
commit | b90affac92455466f23bfe98d5f1448d8551f26d (patch) | |
tree | 3169151712255070b560a92db45c851edb7ae506 /plugins/CoreHome/angularjs/common | |
parent | 7a8e0894a78f1864f3c385c4cd34ed928b8d3937 (diff) |
Ensure dates calculated with JS are never before first allowed date (#13348)
Diffstat (limited to 'plugins/CoreHome/angularjs/common')
-rw-r--r-- | plugins/CoreHome/angularjs/common/services/periods.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/CoreHome/angularjs/common/services/periods.js b/plugins/CoreHome/angularjs/common/services/periods.js index 1c02bca2df..ceb04eff9f 100644 --- a/plugins/CoreHome/angularjs/common/services/periods.js +++ b/plugins/CoreHome/angularjs/common/services/periods.js @@ -224,6 +224,25 @@ endDate = endPeriod.getDateRange()[1]; } + var firstWebsiteDate = new Date(1991, 7, 6); + if (startDate - firstWebsiteDate < 0) { + switch (childPeriodType) { + case 'year': + startDate = new Date(1992, 0, 1); + break; + case 'month': + startDate = new Date(1991, 8, 1); + break; + case 'week': + startDate = new Date(1991, 8, 12); + break; + case 'day': + default: + startDate = firstWebsiteDate; + break; + } + } + return new RangePeriod(startDate, endDate, childPeriodType); }; |