Skip to content

Commit

Permalink
Merge pull request #2769 from AlchemyCMS/backport/7.0-stable/pr-2767
Browse files Browse the repository at this point in the history
[7.0-stable] Do not include timezone in datepickers only displaying date
  • Loading branch information
tvdeyen committed Mar 5, 2024
2 parents 2685296 + 4b13bf5 commit 6e26edb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/javascript/alchemy_admin/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ export default function Datepicker(scope = document) {
// Initializes the datepickers
datepickerInputs.forEach((input) => {
const type = input.dataset.datepickerType
const enableTime = /time/.test(type)

const options = {
// alchemy_i18n supports `zh_CN` etc., but flatpickr only has two-letter codes (`zh`)
locale: Alchemy.locale.slice(0, 2),
altInput: true,
altFormat: Alchemy.t(`formats.${type}`),
altInputClass: "flatpickr-input",
dateFormat: "Z",
enableTime: /time/.test(type),
enableTime,
noCalendar: type === "time",
time_24hr: Alchemy.t("formats.time_24hr"),
onValueUpdate(_selectedDates, _dateStr, instance) {
Expand All @@ -28,6 +30,11 @@ export default function Datepicker(scope = document) {
)
}
}

if (enableTime) {
options.dateFormat = "Z"
}

flatpickr(input, options)
})
}

0 comments on commit 6e26edb

Please sign in to comment.