Skip to content

Instantly share code, notes, and snippets.

View steventux's full-sized avatar

Steve Laing steventux

View GitHub Profile
@steventux
steventux / gist:1151384
Created August 17, 2011 11:46
ActionView date_select calendar logic in javascript
document.observe("dom:loaded", function() {
var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var dateEl = $('project_expiry_date_3i');
var monthEl = $('project_expiry_date_2i');
var yearEl = $('project_expiry_date_1i');
if (dateEl && monthEl && yearEl) {
var currentDateIndex = dateEl.selectedIndex;
function leapYearAdjustedDays() {
var daysInMonth = DAYS_IN_MONTH[monthEl.selectedIndex];
// Leap year calc.