clemens / delocalize

Date/time and number parsing for Rails.

Home Page:http://www.railway.at

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Regexp does not support many strptime formats

jonsgreen opened this issue · comments

I am noticing that the currently the REGEXP constant does not support many common strptime formats so for example if I set a time format as: "%m/%d/%Y %l:%M %p" then the format gets ignored because the %l and %p are not replaced when matching here.

I see that there is a note "extend/change this according to your needs by merging your custom regexps". This does seem well documented and I am curious what was is your thinking about all this?

You can do something like:

Delocalize::Parsers::DateTime::REGEXPS.merge!("%l"=> "YOUR REGEX HERE")

I think you can send a pull request, so we can integrate. Maybe it would be useful to add more formats from here.