Open NishaJKulal opened 2 years ago
Could you please provide details on what is the right approach to use custom Date time picker?
The one mentioned below does not work https://danielykpan.github.io/date-time-picker/#locale-formats
We have tried implementing referring to the code snippet in - https://github.com/danielmoncada/date-time-picker/issues/130#issuecomment-894207777
We need to inject a service in the CustomDateTimePicker class. Since we extend NativeDateTimeAdapter class it throws error while we inject owlDateTimeLocale which is a private string variable.
custom-date-time-format.ts
@Injectable({providedIn: 'root'}) export class CustomDateTimeAdapter extends NativeDateTimeAdapter { constructor( owlDateTimeLocale: string, platform: Platform, private readonly languageDetail: LanguageDetailService ) { super(owlDateTimeLocale, platform) } format(date: Date, format): string { if (!this.isValid(date)) { throw Error('JSNativeDate: Cannot format invalid date.'); } return ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear(); }
Angular version used: 14.1.0
Could you please provide details on what is the right approach to use custom Date time picker?
The one mentioned below does not work https://danielykpan.github.io/date-time-picker/#locale-formats
We have tried implementing referring to the code snippet in - https://github.com/danielmoncada/date-time-picker/issues/130#issuecomment-894207777
We need to inject a service in the CustomDateTimePicker class. Since we extend NativeDateTimeAdapter class it throws error while we inject owlDateTimeLocale which is a private string variable.
custom-date-time-format.ts
@Injectable({providedIn: 'root'}) export class CustomDateTimeAdapter extends NativeDateTimeAdapter { constructor( owlDateTimeLocale: string, platform: Platform, private readonly languageDetail: LanguageDetailService ) { super(owlDateTimeLocale, platform) } format(date: Date, format): string { if (!this.isValid(date)) { throw Error('JSNativeDate: Cannot format invalid date.'); } return ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear(); }
Angular version used: 14.1.0