Add wrapper function for formatting datetime

This makes it easier to use and correctly converts params which
formatTime expects.
This commit is contained in:
Michal Čihař 2013-07-08 14:43:40 +02:00
parent 625bc13c14
commit acb997206e
3 changed files with 21 additions and 7 deletions

View File

@ -753,7 +753,7 @@ function updatePrefsDate()
var d = new Date(window.localStorage['config_mtime_local']);
var msg = PMA_messages.strSavedOn.replace(
'@DATE@',
$.datepicker.formatDate('yy-mm-dd', d) + ' ' + $.datepicker.formatTime('HH:mm', d)
PMA_formatDateTime(d)
);
$('#opts_import_local_storage div.localStorage-exists').html(msg);
}

View File

@ -3919,3 +3919,21 @@ $('a.login-link').live('click', function (e) {
$(window).resize(DynamicBoxes);
});
})();
/**
* Formats timestamp for display
*/
function PMA_formatDateTime(date, seconds) {
var result = $.datepicker.formatDate('yy-mm-dd', date);
var timefmt = 'HH:mm';
if (seconds) {
timefmt = 'HH:mm:ss';
}
return result + ' ' + $.datepicker.formatTime(
timefmt, {
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
);
}

View File

@ -1424,13 +1424,9 @@ AJAX.registerOnload('server_status_monitor.js', function () {
function PMA_getLogAnalyseDialog(min, max) {
$('#logAnalyseDialog input[name="dateStart"]')
.val(
$.datepicker.formatDate('yy-mm-dd', min) + ' ' + $.datepicker.formatTime('HH:mm:ss', min)
);
.val(PMA_formatDateTime(min, true));
$('#logAnalyseDialog input[name="dateEnd"]')
.val(
$.datepicker.formatDate('yy-mm-dd', max) + ' ' + $.datepicker.formatTime('HH:mm:ss', max)
);
.val(PMA_formatDateTime(max, true));
var dlgBtns = { };