Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
tischsoic committed Mar 15, 2019
1 parent 556a7e6 commit aff57a6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/bundle/Resources/public/js/scripts/fieldType/ezdatetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
const datetimeConfig = {
enableTime: true,
time_24hr: true,
formatDate: (date) => new Date(date).toLocaleString(),
};
const updateInputValue = (sourceInput, dates) => {
const event = new CustomEvent(EVENT_VALUE_CHANGED);
Expand All @@ -76,7 +77,7 @@
return;
}

const selectedDate = dates[0];
const selectedDate = new Date(dates[0]);
const selectedDateWithUserTimezone = convertDateToTimezone(selectedDate, userTimezone, true);
const timestamp = Math.floor(selectedDateWithUserTimezone.valueOf() / 1000);

Expand All @@ -94,8 +95,8 @@
const sourceInput = field.querySelector(SELECTOR_INPUT);
const flatPickrInput = field.querySelector(SELECTOR_FLATPICKR_INPUT);
const btnClear = field.querySelector('.ez-data-source__btn--clear-input');
const secondsEnabled = sourceInput.dataset.seconds === '1';
const formatDate = secondsEnabled ? (date) => date.toLocaleString() : (date) => eZ.helpers.timezone.formatDate(date);
// const secondsEnabled = sourceInput.dataset.seconds === '1';
// const formatDate = secondsEnabled ? (date) => date.toLocaleString() : (date) => eZ.helpers.timezone.formatDate(date);
let defaultDate = null;

if (sourceInput.value) {
Expand All @@ -110,8 +111,8 @@
Object.assign({}, datetimeConfig, {
onChange: updateInputValue.bind(null, sourceInput),
defaultDate,
enableSeconds: secondsEnabled,
formatDate,
enableSeconds: !!parseInt(sourceInput.dataset.seconds, 10),
// formatDate,
})
);

Expand Down

0 comments on commit aff57a6

Please sign in to comment.