ember-power-datepicker
ember-power-datepicker copied to clipboard
Address Moment deprecation
@cibernox Can we address the below issue in picker?
moment.min.js:6 Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.
Error
at Function.createFromInputFallback (http://localhost:4200/assets/vendor.js:137353:7002)
at da (http://localhost:4200/assets/vendor.js:137353:7484)
at Ba (http://localhost:4200/assets/vendor.js:137353:11268)
at Aa (http://localhost:4200/assets/vendor.js:137353:11165)
at za (http://localhost:4200/assets/vendor.js:137353:10886)
at Ca (http://localhost:4200/assets/vendor.js:137353:11581)
at Da (http://localhost:4200/assets/vendor.js:137353:11615)
at n.hb [as isSame] (http://localhost:4200/assets/vendor.js:137353:16244)
at Class.dayIsSelected (http://localhost:4200/assets/vendor.js:183539:44)
at Class.buildDay (http://localhost:4200/assets/vendor.js:183530:26)
This occurs cause moment works without format only for
moment("2014-04-25T01:32:21.196Z"); // iso string, utc timezone moment("2014-04-25T01:32:21.196+0600"); // iso string with timezone moment("2014 04 25", "YYYY MM DD"); // string with format
This happens when we display the date in a particular format apart from the default once moment acepts inside the trigger textbox and we click on the trigger again, looks like the date is being read from the textbox value apart from selected property.
What do you think? Also is there a way the datepicker can return dates in a particular format such as MMM DD YYYY, as of now the docs are not updated so am not sure.
Since we cant always know the format I do the below:
getMomentFromUnknownFormat(date, toFormat) {
let momentDate = moment(new Date(date).toLocaleDateString(), 'MM/DD/YYYY');
return toFormat ? momentDate.format(toFormat) :momentDate ;
}
Initial issue discussion in calendar/issues/90
I labeled it as a bug but I don't think I'm going to have must time in the next 2/3 weeks. If you can give it a try I should be able to review it.
About the format, there is the format option:
https://github.com/cibernox/ember-power-datepicker/blob/master/addon/components/power-datepicker.js#L10
https://github.com/cibernox/ember-power-datepicker/blob/master/addon/templates/components/power-datepicker.hbs#L41
@cibernox sure will do it over the weekend