Skip to content
Extraits de code Groupes Projets
Valider a16ea5af rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

use internal Date class to calculate timezone difference

Conflicts:
	plugins/ScheduledReports/javascripts/pdf.js
	plugins/ScheduledReports/templates/_addReport.twig
parent f418b4e0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Chargement en cours
......@@ -8,6 +8,7 @@
*/
namespace Piwik\Updates;
use Piwik\Date;
use Piwik\Plugins\ScheduledReports\API as ScheduledReportsAPI;
use Piwik\Plugins\ScheduledReports\Model as ScheduledReportsModel;
use Piwik\Site;
......@@ -33,13 +34,10 @@ class Updates_2_16_3_b3 extends PiwikUpdates
protected function adjustTimezoneBySite($hour, $idSite)
{
$timezone = Site::getTimezoneFor($idSite);
try {
$dateTimeZone = new \DateTimeZone($timezone);
} catch(\Exception $e) {
return;
}
$timeZoneDifference = -ceil($dateTimeZone->getOffset(new \DateTime()) / 3600);
$timezone = Site::getTimezoneFor($idSite);
$timestampUTC = Date::today()->getTimestampUTC();
$timestampZone = Date::adjustForTimezone($timestampUTC, $timezone);
$timeZoneDifference = -ceil(($timestampZone - $timestampUTC) / 3600);
return (24 + $hour + $timeZoneDifference) % 24;
}
}
......@@ -8,6 +8,7 @@
*/
namespace Piwik\Plugins\ScheduledReports;
use Piwik\Date;
use Piwik\Piwik;
use Piwik\Plugins\LanguagesManager\LanguagesManager;
use Piwik\Plugins\SegmentEditor\API as APISegmentEditor;
......@@ -27,9 +28,11 @@ class Controller extends \Piwik\Plugin\Controller
$this->setGeneralVariablesView($view);
$siteTimezone = $this->site->getTimezone();
$dateTimeZone = new \DateTimeZone($siteTimezone);
$view->timeZoneDifference = $dateTimeZone->getOffset(new \DateTime()) / 3600;
$timestampUTC = Date::today()->getTimestampUTC();
$timestampZone = Date::adjustForTimezone($timestampUTC, $siteTimezone);
$view->timeZoneDifference = ($timestampZone - $timestampUTC) / 3600;
$view->countWebsites = count(APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess());
// get report types
......
......@@ -16,7 +16,11 @@
this.reportHours = [];
for (var i = 0; i < 24; i++) {
this.reportHours.push({key: i + '', value: i + ''});
if ((timeZoneDifference*2) % 2 != 0) {
this.reportHours.push({key: i + '.5', value: i + ':30'});
} else {
this.reportHours.push({key: i + '', value: i + ''});
}
}
function scrollToTop()
......@@ -39,7 +43,7 @@
}
function adjustHourToTimezone(hour, difference) {
return '' + ((24 + parseInt(hour) + difference) % 24);
return '' + ((24 + parseFloat(hour) + difference) % 24);
}
function updateReportHourUtc (report) {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter