date_select conversion
<%=date_select(:date,'',:start_year => 1950,:include_blank => false, :default => { :year => '1970' })%> def convert_date(obj) return “#{obj[‘(1i)’]}-#{obj[‘(2i)’]}-#{obj[‘(3i)’]}” end
11308 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
<%=date_select(:date,'',:start_year => 1950,:include_blank => false, :default => { :year => '1970' })%> def convert_date(obj) return “#{obj[‘(1i)’]}-#{obj[‘(2i)’]}-#{obj[‘(3i)’]}” end
<%= date_select('range', 'start_date', :order => [:month, :day, :year])%>
@start_date = Date.civil(params[:range][:"start_date(1i)"].to_i,params[:range][:"start_date(2i)"].to_i,params[:range][:"start_date(3i)"].to_i)
# put is app_root/public/javascript/application.js function set_today(model, atrib) { t3 = document.getElementById(model + '_' + atrib + '_3i'); var dt = new Date(); t3.selectedIndex = dt.getDate(); t2 = document.getElementById(model + '_' + atrib + '_2i') t2.selectedIndex = dt.getMonth() + 1; t1 = document.getElementById(model + '_' + atrib + '_1i') for (i = 0; i < t1.length; i++) { if (t1.options[i].text == dt.getFullYear()) { t1.selectedIndex = i; } } }
<a href="javascript: set_today('model_name', 'column_name');">today?</a>