Created
April 19, 2011 18:57
-
-
Save aiwilliams/929272 to your computer and use it in GitHub Desktop.
date_select Ruby vs. CoffeeScript
This file contains hidden or 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
months = [null,'January','February','March','April','May','June','July','August','September','October','November','December'] | |
mops = dops = yops = '' | |
for n in [1..12] | |
mops += "<option value='#{n}'>#{months[n]}</option>" | |
for n in [1..31] | |
dops += "<option value='#{n}'>#{n}</option>" | |
y = (new Date()).get('Year') | |
for n in [(y-80)..y] | |
yops += "<option value='#{n}'>#{n}</option>" | |
"<select name='born_on_month'>#{mops}</select>" + | |
"<select name='born_on_day'>#{dops}</select>" + | |
"<select name='born_on_year'>#{yops}</select>" |
This file contains hidden or 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
%select(name="born_on_month") | |
- (1..12).each do |number| | |
%option(value=number)= Date::MONTHNAMES[number] | |
%select(name="born_on_day") | |
- (1..31).each do |number| | |
%option(value=number)= number | |
%select(name="born_on_year") | |
- y = Date.today.year | |
- ((y-80)..y).each do |number| | |
%option(value=number)= number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment