gr2m / moment-parseformat

A moment.js plugin to extract the format of a date/time string
http://gr2m.github.io/moment-parseformat
Apache License 2.0
45 stars 30 forks source link

format problem #6

Closed keminming closed 9 years ago

keminming commented 10 years ago

Thursday, February 6th, 2014 9:20pm this format is recognized as invalid by moment.js

gr2m commented 10 years ago

I can't reproduce the issue here.

> moment.parseFormat("Thursday, February 6th, 2014 9:20pm")
  "dddd, MMMM Do, YYYY h:mma"
> moment().format("dddd, MMMM Do, YYYY h:mma")
  "Tuesday, June 24th, 2014 9:41am"

Works as expected for me. Can you provide a code example that leads to an error or wrong behavior?

keminming commented 10 years ago

im using moment.js 2.6 now. the problem moment.isvailid return false for that two input in strict mode. i checked the parse result and find its wrong with Do. the regex in moment.js cant recognize st,rd,nd,th. i dont know if they have new version or solution now. i just modified the regex code. and it works now. On Jun 24, 2014 2:43 AM, "Gregor Martynus" notifications@github.com wrote:

I can't reproduce the issue here.

moment.parseFormat(''Thursday, February 6th, 2014 9:20pm'') "dddd, MMMM Do, YYYY h:mma" moment().format("dddd, MMMM Do, YYYY h:mma") "Tuesday, June 24th, 2014 9:41am"

Works as expected for me. Can you provide a code example that leads to an error or wrong behavior?

— Reply to this email directly or view it on GitHub https://github.com/gr2m/moment.parseFormat/issues/6#issuecomment-46941003 .

gr2m commented 10 years ago

Got it. I thought I fixed it myself in https://github.com/moment/moment/pull/1475, but either it has been removed or it doesn't work properly, I'll look into it.

For reference, that's how to reproduce the problem

moment("Thursday, February 6th, 2014 9:20pm", "dddd, MMMM Do, YYYY h:mma", true).format()
// "Invalid date"
keminming commented 10 years ago

ok, cool. i will check it later thank you. On Jun 24, 2014 2:55 AM, "Gregor Martynus" notifications@github.com wrote:

Got it. I thought I fixed it myself in moment/moment#1475 https://github.com/moment/moment/pull/1475, but either it has been removed or it doesn't work properly, I'll look into it.

For reference, that's how to reproduce the problem

moment("Thursday, February 6th, 2014 9:20pm", "dddd, MMMM Do, YYYY h:mma", true).format()// "Invalid date"

— Reply to this email directly or view it on GitHub https://github.com/gr2m/moment.parseFormat/issues/6#issuecomment-46941885 .

gr2m commented 9 years ago

It works with latest moment.js (tested with 2.9.0)