Created
October 9, 2012 23:47
-
-
Save jvkumar/3862213 to your computer and use it in GitHub Desktop.
date monkey patching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
https://github.com/datamapper/dm-core/issues/184
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://markgandolfo.com/?p=35
http://stackoverflow.com/questions/6034514/changing-rails-default-date-parse-option-hide-options
http://stackoverflow.com/questions/4470108/when-monkey-patching-a-method-can-you-call-the-overridden-method-from-the-new-i