p-calendar does not use dateFormat from locale although the docs imply it
the docs suggest that you can provide the dateFormat as part of the locale.
export class MyModel {
en: any;
ngOnInit() {
this.en = {
firstDayOfWeek: 0,
dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"],
monthNames: [ "January","February","March","April","May","June","July","August","September","October","November","December" ],
monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ],
today: 'Today',
clear: 'Clear',
dateFormat: 'mm/dd/yy'
};
}
}
However p-calendar uses a defined interface of localeSettings that doesn't include dateFormat. Instead it only uses the dateFormat from the direct input.
export interface LocaleSettings {
firstDayOfWeek?: number;
dayNames: string[];
dayNamesShort: string[];
dayNamesMin: string[];
monthNames: string[];
monthNamesShort: string[];
today: string;
clear: string;
}
Either remove dateFormat from the docs and explicitly state that the dateFormat needs to be provided seperately or use the dateFormat from the LocaleSettings.
I personally would prefer the second option.
The same issue here when I use 'es' locale. It always displays date in the default dateFormat. So it would be better if it will pick the dateFormat from the locale if dateFormat was not specified.
Cheers.
@cagataycivici some news here? Would you accept a PR for this bug or only the primeng team can do it?
any update ?
Same problem.
Unable to replicate with PrimeNG 9, if the issue persists please create a new ticket with a test case reproducing the issue e.g. stackblitz or a github repo and it will be reviewed by our team once again.
The current code is;
getDateFormat() {
return this.dateFormat || this.locale.dateFormat;
}
Unable to replicate with PrimeNG 9, if the issue persists please create a new ticket with a test case reproducing the issue e.g. stackblitz or a github repo and it will be reviewed by our team once again.
The current code is;
getDateFormat() { return this.dateFormat || this.locale.dateFormat; }
The issue is that the dateFormat has a default value so it is always preferred:
@Input() dateFormat: string = 'mm/dd/yy';
I would also suggest that the dateFormat from the locale is preferred over the other one, like this:
return this.locale.dateFormat || this.dateFormat