Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PHP timezone conversor instead of relying on RrdGraphJS #16049

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions includes/html/print-date-selector.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ class="btn btn-default"
value="Update"
onclick="submitCustomRange(this.form);">
</form>
<script src="<?php echo asset('js/RrdGraphJS/moment-timezone-with-data.js'); ?>"></script>
<script type="text/javascript">
$(function () {
var ds_datefrom = new Date(<?php echo \LibreNMS\Util\Time::parseAt($graph_array['from']); ?>*1000);
var ds_dateto = new Date(<?php echo \LibreNMS\Util\Time::parseAt($graph_array['to']); ?>*1000);
var ds_tz = '<?php echo session('preferences.timezone'); ?>';
if (ds_tz) {
ds_datefrom = moment.tz(ds_datefrom, ds_tz);
ds_dateto = moment.tz(ds_dateto, ds_tz);
} else {
ds_datefrom = moment(ds_datefrom);
ds_dateto = moment(ds_dateto);
}
<?php
$ds_tz = session('preferences.timezone');
$ds_datefrom = new DateTime();
$ds_datefrom->setTimezone(new DateTimeZone($ds_tz));
$ds_datefrom->setTimestamp($graph_array['from']);
$ds_dateto = new DateTime();
$ds_dateto->setTimezone(new DateTimeZone($ds_tz));
$ds_dateto->setTimestamp($graph_array['to']);
?>
var ds_datefrom = new Date('<?php echo $ds_datefrom->format('D M d Y H:i:s O'); ?>');
var ds_dateto = new Date('<?php echo $ds_dateto->format('D M d Y H:i:s O'); ?>');
var ds_tz = '<?php echo $ds_tz; ?>';

$("#dtpickerfrom").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false, icons: {time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-chevron-up", down: "fa fa-chevron-down", previous: "fa fa-chevron-left", next: "fa fa-chevron-right", today: "fa fa-calendar-check-o", clear: "fa fa-trash-o", close: "fa fa-close"}, defaultDate: ds_datefrom, timeZone: ds_tz});
$("#dtpickerto").datetimepicker({useCurrent: true, sideBySide: true, useStrict: false, icons: {time: "fa fa-clock-o", date: "fa fa-calendar", up: "fa fa-chevron-up", down: "fa fa-chevron-down", previous: "fa fa-chevron-left", next: "fa fa-chevron-right", today: "fa fa-calendar-check-o", clear: "fa fa-trash-o", close: "fa fa-close"}, defaultDate: ds_dateto, timeZone: ds_tz});
Expand Down