Search code examples
javascriptdatedatejs

datejs parsing some month is not working


I'm using date-fr-FR.js

When I'm doing this

Date.parse("5 juillet 2012")

it's returning null

But when I do this

Date.parse("5 juil. 2012")

it's returning the right date, someone have an idea ? Thanks


Solution

  • Looking at the source for fr-FR.js (r191) which is used to build date-fr-FR.js, there seems to be is a mistake in the regular expressions that are used to determine the months, for that particular month it reads:

    jul: /^juil(.(let)?)?/i,
    

    which means it'll work with Date.parse("5 juilXlet 2012"), Date.parse("5 juil 2012") and Date.parse("5 juil. 2012") but not with Date.parse("5 juillet 2012")!

    I think it should be something like this:

    /^juil(\.|(let))?/i
    

    Not that that will be of any help to you! I suggest you just always use the short names unless you can get that file fixed.