partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 713ca5bbc19121f055c642ef79b5918cd555769f
parent 9ed81c53c796c2513ca4f671ee5f0a7bd14c1659
Author: Felicitus <felicitus@felicitus.org>
Date:   Sun, 11 Sep 2011 12:37:00 +0200

Sanity: Swap start and end date if end < start

Diffstat:
Msrc/de/RaumZeitLabor/PartKeepr/Statistic/StatisticService.php | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/de/RaumZeitLabor/PartKeepr/Statistic/StatisticService.php b/src/de/RaumZeitLabor/PartKeepr/Statistic/StatisticService.php @@ -67,6 +67,11 @@ class StatisticService extends Service { $start = \DateTime::createFromFormat("Y-m-d H:i:s", $this->getParameter("startDateTime")); $end = \DateTime::createFromFormat("Y-m-d H:i:s", $this->getParameter("endDateTime")); + if ($start->getTimestamp() > $end->getTimestamp()) { + // Swap both times + list($start, $end) = array($end, $start); + } + if ($this->hasParameter("sampleSize")) { $sampleSize = $this->getParameter("sampleSize"); } else { @@ -127,7 +132,10 @@ class StatisticService extends Service { $record["start"] = $queryStartTime->format("Y-m-d H:i:s"); - $aRecords[] = $record; + if ($record["parts"] !== null) { + $aRecords[] = $record; + } + $queryStartTime->add(new \DateInterval("PT".$intervalSize."S")); $queryEndTime->add(new \DateInterval("PT".$intervalSize."S"));