From acb997206ea4bfbc4e8a4c2649fdebe2c1098751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 8 Jul 2013 14:43:40 +0200 Subject: [PATCH] Add wrapper function for formatting datetime This makes it easier to use and correctly converts params which formatTime expects. --- js/config.js | 2 +- js/functions.js | 18 ++++++++++++++++++ js/server_status_monitor.js | 8 ++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/js/config.js b/js/config.js index a7a4b43ce8..f8d290ee4e 100644 --- a/js/config.js +++ b/js/config.js @@ -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); } diff --git a/js/functions.js b/js/functions.js index c83b06e319..ef64fdb989 100644 --- a/js/functions.js +++ b/js/functions.js @@ -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() + } + ); +} diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index ed3574aee1..c093fea83a 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -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 = { };