Created
December 22, 2016 18:19
-
-
Save eiwi1101/c90526fb499711eb34d455f32642ba79 to your computer and use it in GitHub Desktop.
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
# As if Ruby didn't make dates any easier, this! | |
# (#method_missing is disgusting and I love it.) | |
# | |
# 25.december 2015 #=> Fri, 25 Dec 2015 | |
# | |
class Fixnum | |
def method_missing(month, year=nil) | |
Date::MONTHNAMES.each_with_index do |m, i| | |
return Date.new year, i, self if m && month.to_s.casecmp(m)==0 | |
end | |
super | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment