2014-06-13 Sergio Martin <sergio.martin@artica.es>

* extensions/realtime_graphs.php
	extensions/realtime_graphs/realtime_graphs.js: Fix timezone
	differences in realtime graphs when client (browser) and
	server (console instance host) have different timezone.
	Now it takes always the server timezone.
	Ticket: #853



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10187 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2014-06-13 12:07:37 +00:00
parent cae602901e
commit 71ad99ff03
3 changed files with 21 additions and 0 deletions

View File

@ -1,3 +1,12 @@
2014-06-13 Sergio Martin <sergio.martin@artica.es>
* extensions/realtime_graphs.php
extensions/realtime_graphs/realtime_graphs.js: Fix timezone
differences in realtime graphs when client (browser) and
server (console instance host) have different timezone.
Now it takes always the server timezone.
Ticket: #853
2014-06-13 Sergio Martin <sergio.martin@artica.es>
* include/functions_api.php: Add doc info to pagerduty

View File

@ -123,6 +123,9 @@ function pandora_realtime_graphs () {
echo '<script type="text/javascript" src="extensions/realtime_graphs/realtime_graphs.js"></script>';
echo '<script type="text/javascript" src="include/javascript/pandora_snmp_browser.js"></script>';
echo '<link rel="stylesheet" type="text/css" href="extensions/realtime_graphs/realtime_graphs.css"></style>';
// Store servers timezone offset to be retrieved from js
set_js_value('timezone_offset', date('Z', time()));
}
extensions_add_operation_menu_option (__('Realtime graphs'), null, null, "v1r1");

View File

@ -5,6 +5,15 @@ var options = {
xaxis: {
tickFormatter: function (timestamp, axis) {
var date = new Date(timestamp * 1000);
var server_timezone_offset = get_php_value('timezone_offset');
var local_timezone_offset = date.getTimezoneOffset()*60*-1;
if (server_timezone_offset != local_timezone_offset) {
// If timezone of server and client is different, adjust the time to the server
date = new Date((timestamp + (server_timezone_offset - local_timezone_offset)) * 1000);
}
var hours = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
var minutes = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes());
var seconds = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());