Created
November 5, 2012 22:11
-
-
Save remi/4020721 to your computer and use it in GitHub Desktop.
Natural Dates in Ruby
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
#!/usr/bin/env ruby | |
require "date" | |
class Fixnum | |
Date::MONTHNAMES[1..-1].each_with_index do |month, index| | |
define_method month.downcase do |year| | |
Date.new(year, index+1, self) | |
end | |
end | |
end | |
puts 30.october 2006 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment