Skip to content
Extraits de code Groupes Projets
Valider 0813d6cb rédigé par mattpiwik's avatar mattpiwik
Parcourir les fichiers

Hopefully now making sense in this method - looking forward to tests passing....

git-svn-id: http://dev.piwik.org/svn/trunk@2674 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 2ac68498
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -498,14 +498,28 @@ class Piwik_Date
$minutes = 0;
if($n != round($n))
{
$minutes = abs($n - floor(abs($n))) * 60;
if($n >= 1 || $n <= -1)
{
$extraMinutes = floor(abs($n));
if($isNegative)
{
$extraMinutes = -$extraMinutes;
}
$minutes = abs($n - $extraMinutes) * 60;
if($isNegative) {
$minutes *= -1;
}
}
else
{
$minutes = $n * 60;
}
$n = floor(abs($n));
if($isNegative) {
$minutes *= -1;
$n *= -1;
}
}
$ts = $this->timestamp + $minutes * 60 + $n * 3600;
$ts = $this->timestamp + round($minutes * 60) + $n * 3600;
return new Piwik_Date( (int)$ts, $this->timezone );
}
......
......@@ -100,6 +100,7 @@ class Piwik_API_API
/**
* Triggers a hook to ask plugins for available Reports.
* Returns metadata information about each report (category, name, dimension, metrics, etc.)
*
* @param string $idSites Comma separated list of website Ids
* @return array
......@@ -341,6 +342,9 @@ class Piwik_API_API
);
}
/*
* Loads reports metadata, then return the requested one (possibly matching parameters, if passed)
*/
private function getMetadata($idSite, $apiModule, $apiAction, $apiParameters = array())
{
static $reportsMetadata = array();
......
......@@ -126,8 +126,15 @@ class Test_Piwik_Date extends UnitTestCase
function test_addHour()
{
// add partial hours
// add partial hours less than 1
$dayStart = '2010-03-28 00:00:00';
$dayExpected = '2010-03-28 00:18:00';
$date = Piwik_Date::factory($dayStart)->addHour(0.3);
$this->assertEqual($date->getDatetime(), $dayExpected);
$date = $date->subHour(0.3);
$this->assertEqual($date->getDatetime(), $dayStart);
// add partial hours
$dayExpected = '2010-03-28 05:45:00';
$date = Piwik_Date::factory($dayStart)->addHour(5.75);
$this->assertEqual($date->getDatetime(), $dayExpected);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter