Skip to content

Instantly share code, notes, and snippets.

@remi
Created November 5, 2012 22:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save remi/4020721 to your computer and use it in GitHub Desktop.
Save remi/4020721 to your computer and use it in GitHub Desktop.
Natural Dates in Ruby
#!/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