Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Moment deprecation #18

Open
Vishwaas opened this issue May 19, 2017 · 3 comments
Open

Address Moment deprecation #18

Vishwaas opened this issue May 19, 2017 · 3 comments
Labels

Comments

@Vishwaas
Copy link
Contributor

@cibernox Can we address the below issue in picker?

Moment Issue

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 ;
 }
@Vishwaas
Copy link
Contributor Author

Initial issue discussion in calendar/issues/90

@cibernox cibernox added the bug label May 19, 2017
@cibernox
Copy link
Owner

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

@Vishwaas
Copy link
Contributor Author

@cibernox sure will do it over the weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants