Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.settings.formatDate = (date, format) => {
// Only format this if this is the altFormat and the form is readOnly.
if (this.settings.readOnly && (format === this.settings.altFormat)) {
if (this.settings.saveAs === 'text' || this.loadZones()) {
return Flatpickr.formatDate(date, format);
}
return formatOffset(Flatpickr.formatDate.bind(Flatpickr), date, format, this.timezone);
}
return Flatpickr.formatDate(date, format);
};
export function randomDate() {
const start = new Date(MIN_APOD_DATE.split("-"));
const end = new Date();
const date = new Date(
start.getTime() + Math.random() * (end.getTime() - start.getTime())
);
return flatpickr.formatDate(date, DATE_FORMAT);
}
export function today() {
return flatpickr.formatDate(new Date(), DATE_FORMAT);
}
export function formatDate(date) {
return flatpickr.formatDate(date, DATE_FORMAT);
}
onChange(date) {
this.formattedEl.value = date.length ? flatpickr.formatDate(date[0], 'Y-m-dTH:i') : '';
this.toggleClearBtn();
}
export function adjacentDate(dateString, direction) {
let adjDate = new Date(actualDate(dateString).getTime());
adjDate = new Date(adjDate.setDate(adjDate.getDate() + direction));
return flatpickr.formatDate(adjDate, DATE_FORMAT);
}