Skip to content

Commit 3d6dd1f

Browse files
Merge pull request #5789 from christianbeeznest/ofaj-21592
Internal: Fix date and time format in datepickers by locale - refs BT#21592
2 parents edc5934 + ce59854 commit 3d6dd1f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

public/main/inc/lib/formvalidator/Element/DatePicker.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ private function getElementJS(): string
101101
$localeCode = $this->getLocaleCode();
102102
$id = $this->getAttribute('id');
103103

104+
$altFormat = ($localeCode === 'en') ? 'F d, Y' : 'd F, Y';
105+
104106
return "<script>
105107
document.addEventListener('DOMContentLoaded', function () {
106108
function initializeFlatpickr() {
107109
const fp = flatpickr('#{$id}', {
108110
locale: '{$localeCode}',
109111
altInput: true,
110-
altFormat: '".get_lang('F d, Y')."',
112+
altFormat: '{$altFormat}',
111113
enableTime: false,
112114
dateFormat: 'Y-m-d',
113115
time_24hr: true,

public/main/inc/lib/formvalidator/Element/DateTimePicker.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ private function getElementJS(): string
7272
$localeCode = $this->getLocaleCode();
7373
$id = $this->getAttribute('id');
7474

75+
$altFormat = ($localeCode === 'en') ? 'F d, Y - H:i' : 'd F, Y - H:i';
76+
7577
$js = "<script>
7678
document.addEventListener('DOMContentLoaded', function () {
7779
function initializeFlatpickr() {
7880
const fp = flatpickr('#{$id}', {
7981
locale: '{$localeCode}',
8082
altInput: true,
81-
altFormat: '".get_lang('F d, Y')." ".get_lang('at')." H:i',
83+
altFormat: '{$altFormat}',
8284
enableTime: true,
8385
dateFormat: 'Y-m-d H:i',
8486
time_24hr: true,

src/CoreBundle/DataFixtures/ExtraFieldFixtures.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ public static function getExtraFields(): array
389389
'display_text' => 'GDPR compliance',
390390
'item_type' => ExtraField::USER_FIELD_TYPE,
391391
'value_type' => ExtraField::FIELD_TYPE_CHECKBOX,
392+
'visible_to_self' => true,
393+
'changeable' => true,
392394
],
393395
[
394396
'variable' => 'isFromNewLogin',

0 commit comments

Comments
 (0)