ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

unable to override date parse and format #75

Closed gufi closed 7 years ago

gufi commented 7 years ago

The methods momentFormatDate and momentParse appear to still be called reguardless of overriding the methods in the example.

Personally I don't mind importing moment.js but figured I would notify that overriding them does not work as expected if you don't.

doing the following will however allow full override

// Override Date object formatter
DateTime.formatDate = (date: Date,dateOnly:boolean) : string => { return date.toDateString(); };
DateTime.momentFormatDate = (date: Date, dateFormat:string): string=> { return DateTime.formatDate(date,true);};
// Override Date object parser
DateTime.parse = (str: any): Date => { return new Date(str); } ;
DateTime.momentParse = DateTime.parse;
allenhwkim commented 7 years ago

Thank you for reporting this. I will look into it later

allenhwkim commented 7 years ago

released with 0.11.0 please verify the change.

HerokunTan commented 7 years ago

oh!this is what i want