Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jvkumar
Created October 9, 2012 23:47
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 jvkumar/3862213 to your computer and use it in GitHub Desktop.
Save jvkumar/3862213 to your computer and use it in GitHub Desktop.
date monkey patching
require 'date'
class Date
class << self
alias_method :original_parse, :parse
end
def self.parse(str='-4712-01-01', comp=true,start=ITALY)
if str == '0000-00-00 00:00:00'
str = '1970-01-01 00:00:00'
end
self.original_parse(str, comp, start)
end
end
puts Date.parse('0000-00-00 00:00:00')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment