Merge pull request #1721 from prometheus/console-time

Do our own date parsing in console template graph controls.
This commit is contained in:
Brian Brazil 2016-06-10 10:29:02 +01:00 committed by GitHub
commit a3c4beb6ee
2 changed files with 43 additions and 42 deletions

File diff suppressed because one or more lines are too long

View File

@ -198,7 +198,8 @@ PromConsole.TimeControl.prototype.getEndDate = function() {
if (this.endElement.value === '') { if (this.endElement.value === '') {
return null; return null;
} }
return new Date(this.endElement.value).getTime(); var dateParts = this.endElement.value.split(/[- :]/)
return Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2], dateParts[3], dateParts[4]);
}; };
PromConsole.TimeControl.prototype.getOrSetEndDate = function() { PromConsole.TimeControl.prototype.getOrSetEndDate = function() {
@ -208,13 +209,13 @@ PromConsole.TimeControl.prototype.getOrSetEndDate = function() {
} }
date = new Date(); date = new Date();
this.setEndDate(date); this.setEndDate(date);
return date; return date.getTime();
}; };
PromConsole.TimeControl.prototype.getHumanDate = function(date) { PromConsole.TimeControl.prototype.getHumanDate = function(date) {
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours(); var hours = date.getUTCHours() < 10 ? '0' + date.getUTCHours() : date.getUTCHours();
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes(); var minutes = date.getUTCMinutes() < 10 ? '0' + date.getUTCMinutes() : date.getUTCMinutes();
return date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate() + " " + return date.getUTCFullYear() + "-" + (date.getUTCMonth()+1) + "-" + date.getUTCDate() + " " +
hours + ":" + minutes; hours + ":" + minutes;
}; };