You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure that there is a real bug here, but perhaps someone could spare some advice and help with a work around.
My users have free form input into date field and i am having some issues detecting if their input is invalid. DD-MMM-YYYY is the standard format in my world.
I noticed this behavior:
moment('01-Aug-2012','DD-MMM-YYYY')._d;
Wed Aug 01 2012 00:00:00 GMT-0600 (MDT)
moment('01-Nam-2012','DD-MMM-YYYY')._d;
Sun Jan 01 2012 00:00:00 GMT-0700 (MST)
Unfortunately moment seems to assume that it hasn't received a month and assumes January. I don't think this is ideal. It would be nice if this could be fixed or if the isValid() call could return false in this case.
I worked around this by just checking without the format
moment('01-Nam-2012').isValid();
false
But my application is internationalized and the moment(String) call would not consider the current global language when parsing.
moment.lang("fr",{Excluded for Brevity});
moment('01-Fev-2012').isValid();
false
Beyond manually parsing user input myself I can't think of a way that I can tell if a french user entered a valid month (01-Fev-2012) or and invalid month (01-Nam-2012) with this library.
Thanks
The text was updated successfully, but these errors were encountered:
Not sure that there is a real bug here, but perhaps someone could spare some advice and help with a work around.
My users have free form input into date field and i am having some issues detecting if their input is invalid. DD-MMM-YYYY is the standard format in my world.
I noticed this behavior:
moment('01-Aug-2012','DD-MMM-YYYY')._d;
moment('01-Nam-2012','DD-MMM-YYYY')._d;
Unfortunately moment seems to assume that it hasn't received a month and assumes January. I don't think this is ideal. It would be nice if this could be fixed or if the isValid() call could return false in this case.
I worked around this by just checking without the format
moment('01-Nam-2012').isValid();
But my application is internationalized and the moment(String) call would not consider the current global language when parsing.
moment.lang("fr",{Excluded for Brevity});
moment('01-Fev-2012').isValid();
Beyond manually parsing user input myself I can't think of a way that I can tell if a french user entered a valid month (01-Fev-2012) or and invalid month (01-Nam-2012) with this library.
Thanks
The text was updated successfully, but these errors were encountered: