Skip to content

Instantly share code, notes, and snippets.

@ColinDKelley
Created August 15, 2014 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ColinDKelley/1ceae2c447bac4dbac66 to your computer and use it in GitHub Desktop.
Save ColinDKelley/1ceae2c447bac4dbac66 to your computer and use it in GitHub Desktop.
Fig leaf to intercept parse with American date formats like 03/04/05
module ParseFigLeaf
def parse(*args)
arg0 = args.first
arg0.is_a?(String) && arg0 =~ /\A\d\d[-\/]\d\d[-\/]\d\d/ and raise "Ambiguous parse format in #{arg0.inspect}"
super
end
end
class << Date
prepend ParseFigLeaf
end
class << Time
prepend ParseFigLeaf
end
class ActiveSupport::TimeZone
prepend ParseFigLeaf
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment