Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/components/FormDatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,16 @@ export default {
return this.dataFormat === "datetime";
},
format() {
return this.datepicker ? getUserDateTimeFormat() : getUserDateFormat();
let format = this.datepicker ? getUserDateTimeFormat() : getUserDateFormat();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a fallback control
format = format || 'YYYY-MM-DD'; // fallback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the functions getUserDateTimeFormat() and getUserDateFormat() already have a fallback defined.

if (this.datepicker) {
// Check if the format already includes time patterns (hh:mm A or HH:mm)
const hasTimePattern = /[Hh]{1,2}:[mM]{1,2}/.test(format);
if (!hasTimePattern) {
// If forceDateTime is true and no time pattern exists, ensure the format includes hh:mm A
format = format.replace(/[\sHh:msaAzZ]/g, '') + ' hh:mm A';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is posible use
format =${format} hh:mm A;
instead of replace?

}
}
return format;
},
classList() {
return {
Expand Down
Loading