Skip to content

Instantly share code, notes, and snippets.

@AKovtunov
Created December 20, 2013 18:30
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 AKovtunov/8059194 to your computer and use it in GitHub Desktop.
Save AKovtunov/8059194 to your computer and use it in GitHub Desktop.
Ruby SpeedSheet
years = (Date.strptime("2013","%Y").year...DateTime.now.year+5).to_a
months = (1..12).to_a.map!{|m| Date::MONTHNAMES[m]}
years_months_hash = years.inject({}){|hsh, year| hsh[year]=months; hsh}
#Will be {:2013=>["January", "Fabruary",..],..}
Date::MONTHNAMES.index(month) #month = "January" => 1
Date::MONTHNAMES[m] #m = 1 => "January"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment