Skip to content

Address Moment deprecation #18

Description

@Vishwaas

@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 ;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions