diff --git a/composer.json b/composer.json index 003598f5f1..0e603895d9 100644 --- a/composer.json +++ b/composer.json @@ -21,6 +21,7 @@ "ezsystems/ezplatform-admin-ui-modules": "^1.4@dev", "ezsystems/ez-support-tools": "^1.0@dev", "ezsystems/ezplatform-design-engine": "^2.0@dev", + "ezsystems/ezplatform-user": "^1.0@dev", "white-october/pagerfanta-bundle": "^1.1", "knplabs/knp-menu-bundle": "^2.1", "mck89/peast": "^1.8", diff --git a/src/bundle/Resources/public/js/scripts/admin.format.date.js b/src/bundle/Resources/public/js/scripts/admin.format.date.js index f0b7e17881..85b0fd7633 100644 --- a/src/bundle/Resources/public/js/scripts/admin.format.date.js +++ b/src/bundle/Resources/public/js/scripts/admin.format.date.js @@ -1,6 +1,36 @@ (function(moment) { - const formatEx = /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g; - const formatMap = { + const formatICUEx = /[GdayLqDeEc]+/g; + const formatICUMap = { + dd: 'DD', + d: 'D', + a: 'A', + y: 'Y', + yy: 'YY', + yyyy: 'YYYY', + LLLL: 'MMMM', + LLL: 'MMM', + LL: 'MM', + L: 'M', + q: 'Q', + D: 'DDD', + eeeeee: 'dd', + eeee: 'dddd', + eee: 'ddd', + ee: 'E', + e: 'E', + EEEEEE: 'dd', + EEEE: 'dddd', + EEE: 'ddd', + EE: 'ddd', + E: 'ddd', + cccccc: 'dd', + cccc: 'dddd', + ccc: 'ddd', + cc: 'E', + c: 'E', + }; + const formatPHPEx = /[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g; + const formatPHPMap = { d: 'DD', D: 'ddd', j: 'D', @@ -57,10 +87,21 @@ }; moment.fn.formatPHP = function(format) { + console.warn('[DEPRECATED] formatPHP function is deprecated'); + console.warn('[DEPRECATED] it will be removed from ezplatform-admin-ui 2.0'); + console.warn('[DEPRECATED] use formatICU instead'); return this.format( - format.replace(formatEx, (phpStr) => { - return typeof formatMap[phpStr] === 'function' ? formatMap[phpStr].call(this) : formatMap[phpStr]; + format.replace(formatPHPEx, (phpStr) => { + return typeof formatPHPMap[phpStr] === 'function' ? formatPHPMap[phpStr].call(this) : formatPHPMap[phpStr]; }) ); }; + + moment.fn.formatICU = function(format) { + const form = format.replace(formatICUEx, (icuStr) => { + return typeof formatICUMap[icuStr] === 'function' ? formatICUMap[icuStr].call(this) : formatICUMap[icuStr]; + }); + + return this.format(form); + }; })(window.moment); diff --git a/src/bundle/Resources/public/js/scripts/helpers/timezone.helper.js b/src/bundle/Resources/public/js/scripts/helpers/timezone.helper.js index 6714620bd0..60fdde94c4 100644 --- a/src/bundle/Resources/public/js/scripts/helpers/timezone.helper.js +++ b/src/bundle/Resources/public/js/scripts/helpers/timezone.helper.js @@ -7,16 +7,16 @@ return moment(date).tz(timezone); }; const formatDate = (date, format = userPreferedFullDateFormat) => { - return moment(date).formatPHP(format); - }; - const formatShortDate = (date, format = userPreferedShortDateFormat) => { - return moment(date).formatPHP(format); + return moment(date).formatICU(format); }; const formatDateWithTimezone = (date, timezone = userPreferedTimezone, format = userPreferedFullDateFormat) => { return formatDate(convertDateToTimezone(date, timezone), format); }; + const formatShortDate = (date, format = userPreferedShortDateFormat) => { + return formatDate(date, format); + }; const formatShortDateWithTimezone = (date, timezone = userPreferedTimezone, format = userPreferedShortDateFormat) => { - return formatDate(convertDateToTimezone(date, timezone), format); + return formatDateWithTimezone(date, timezone, format); }; eZ.addConfig('helpers.timezone', { diff --git a/src/bundle/Resources/views/admin/content_draft/list.html.twig b/src/bundle/Resources/views/admin/content_draft/list.html.twig index 96ddc65d20..32037c86d4 100644 --- a/src/bundle/Resources/views/admin/content_draft/list.html.twig +++ b/src/bundle/Resources/views/admin/content_draft/list.html.twig @@ -75,7 +75,7 @@ {{ row.content_type.name }} {{ admin_ui_config.languages.mappings[row.language].name }} {{ row.version }} - {{ row.modified|localizeddate('medium', 'short', null, ez_user_settings['timezone']) }} + {{ row.modified|ez_full_datetime }}