Visitar URL original
Extract Functions.formatDateTime() to a module · phpmyadmin/phpmyadmin@88025a6 · GitHub
Skip to content

Commit 88025a6

Browse files
committed
Extract Functions.formatDateTime() to a module
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent 648ee27 commit 88025a6

3 files changed

Lines changed: 25 additions & 27 deletions

File tree

‎js/src/modules/config.js‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import $ from 'jquery';
2-
import { Functions } from './functions.js';
32
import { CommonParams } from './common.js';
43
import { ajaxShowMessage } from './ajax-message.js';
54
import isStorageSupported from './functions/isStorageSupported.js';
5+
import formatDateTime from './functions/formatDateTime.js';
66

77
/**
88
* Functions used in configuration forms and on user preferences pages
@@ -658,10 +658,7 @@ function savePrefsToLocalStorage (form) {
658658
*/
659659
function updatePrefsDate () {
660660
var d = new Date(window.localStorage.configMtimeLocal);
661-
var msg = window.Messages.strSavedOn.replace(
662-
'@DATE@',
663-
Functions.formatDateTime(d)
664-
);
661+
var msg = window.Messages.strSavedOn.replace('@DATE@', formatDateTime(d));
665662
$('#opts_import_local_storage').find('div.localStorage-exists').html(msg);
666663
}
667664

‎js/src/modules/functions.js‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3482,28 +3482,6 @@ Functions.onloadLoginForm = () => {
34823482
}
34833483
};
34843484

3485-
/**
3486-
* Formats timestamp for display
3487-
*
3488-
* @param {string} date
3489-
* @param {bool} seconds
3490-
* @return {string}
3491-
*/
3492-
Functions.formatDateTime = function (date, seconds) {
3493-
var result = $.datepicker.formatDate('yy-mm-dd', date);
3494-
var timefmt = 'HH:mm';
3495-
if (seconds) {
3496-
timefmt = 'HH:mm:ss';
3497-
}
3498-
return result + ' ' + $.datepicker.formatTime(
3499-
timefmt, {
3500-
hour: date.getHours(),
3501-
minute: date.getMinutes(),
3502-
second: date.getSeconds()
3503-
}
3504-
);
3505-
};
3506-
35073485
/**
35083486
* Toggle the Datetimepicker UI if the date value entered
35093487
* by the user in the 'text box' is not going to be accepted
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import $ from 'jquery';
2+
3+
/**
4+
* Formats timestamp for display
5+
*
6+
* @param {Date} date
7+
* @param {boolean} seconds
8+
* @return {string}
9+
*/
10+
export default function formatDateTime (date, seconds = false) {
11+
var result = $.datepicker.formatDate('yy-mm-dd', date);
12+
var timefmt = 'HH:mm';
13+
if (seconds) {
14+
timefmt = 'HH:mm:ss';
15+
}
16+
return result + ' ' + $.datepicker.formatTime(
17+
timefmt, {
18+
hour: date.getHours(),
19+
minute: date.getMinutes(),
20+
second: date.getSeconds()
21+
}
22+
);
23+
}

0 commit comments

Comments
 (0)