From 6120e01a3fe97984d1e552bca2faac3792fcdd1c 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. Conflicts: js/functions.js --- js/config.js | 2 +- js/functions.js | 24 +++++++++++++++++++++--- js/server_status_monitor.js | 8 ++------ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/js/config.js b/js/config.js index 734dd07713..fdd0fc4ad7 100644 --- a/js/config.js +++ b/js/config.js @@ -740,7 +740,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 35995346a3..731c137e06 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1894,8 +1894,8 @@ function PMA_SQLPrettyPrint(string) jQuery.fn.PMA_confirm = function(question, url, callbackFn) { var confirmState = PMA_commonParams.get('confirm'); - // when the Confirm directive is set to false in config.inc.php - // and not changed in user prefs, confirmState is "" + // when the Confirm directive is set to false in config.inc.php + // and not changed in user prefs, confirmState is "" // when it's unticked in user prefs, confirmState is 1 if (confirmState === "" || confirmState === "1") { // user does not want to confirm @@ -3526,7 +3526,7 @@ function PMA_tooltip($elements, item, myContent, additionalOptions) tooltipClass: "tooltip", track: true, show: false, - hide: false + hide: false }; $elements.tooltip($.extend(true, defaultOptions, additionalOptions)); @@ -3845,3 +3845,21 @@ $('a.login-link').live('click', function(e) { e.preventDefault(); window.location.reload(true); }); + +/** + * 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 f5f93672b0..1ce9e9af8c 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -1410,13 +1410,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 = { };