Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to parse "%m-%d-Y" #14

Closed
seerahulsingh opened this issue Nov 16, 2015 · 6 comments
Closed

Add ability to parse "%m-%d-Y" #14

seerahulsingh opened this issue Nov 16, 2015 · 6 comments

Comments

@seerahulsingh
Copy link

Hi,

Right now it only parse dates in the strict format of "%m/%d/%Y". Can we use "%m-%d-Y" format also.

With this "%m-%d-Y" format, when I tried to parse it, it raised an exception

ArgumentError: invalid date

@jeremyevans
Copy link
Owner

By design, this library emulates ruby 1.8.7 date parsing, which doesn't parse %m-%d-%Y dates, so I don't plan on adding support for this. Please fork the library if you would like that date format handled.

@seerahulsingh
Copy link
Author

ok, thanks -:)

@djberg96
Copy link

djberg96 commented Jul 7, 2023

In 1.1 and earlier our app was doing this:

require 'american_date'
class << Date
  remove_const(:AMERICAN_DATE_RE)
  AMERICAN_DATE_RE = %r_\A\s*(\d{1,2})[-/](\d{1,2})[-/](\d{4}|\d{2})_.freeze
end

However, this doesn't work in 1.2.x because of the switch to Date.instance_eval.

@jeremyevans
Copy link
Owner

In 1.1 and earlier our app was doing this:

require 'american_date'
class << Date
  remove_const(:AMERICAN_DATE_RE)
  AMERICAN_DATE_RE = %r_\A\s*(\d{1,2})[-/](\d{1,2})[-/](\d{4}|\d{2})_.freeze
end

However, this doesn't work in 1.2.x because of the switch to Date.instance_eval.

Looks like that is a bug in 1.2, because AMERICAN_DATE_RE gets defined at top-level. I'll fix it.

@djberg96
Copy link

Thanks! Any idea when the fix will be pushed out?

@jeremyevans
Copy link
Owner

Hopefully I can release a new version later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants