function days_in_month($month, $year) { return(32 - date("d", mktime(0, 0, 0, $month, 32, $year))); } function arrayTime($lt) { // Given a localtime-type array, return a year/month/day/weekday array. return(array($lt[5] + 1900, $lt[4] + 1, $lt[3], $lt[6] + 1)); } function addDays($dateArray, $delta) { // Given a date in year/month/day[/weekday] array format, add the // given number of days to it, returning a year/month/day/weekday // array. $newlt = localtime(mktime(12, 0, 0, $dateArray[1], $dateArray[2] + $delta, $dateArray[0])); return(arrayTime($newlt)); } function todayArray() { // Return a year/month/day/weekday array for today's date. $lt = localtime(time()); return(arrayTime($lt)); } function nextSaturday($dateArr) { // Given a year/month/day/weekday array, move forward to the next // Saturday (doing nothing if today is Saturday). return(addDays($dateArr, (7 - $dateArr[3]))); } function isThirdSaturday($dateArr) { // Given a year/month/day/weekday array supposedly representing a // Saturday, return TRUE if it is the third Saturday of the month, // FALSE otherwise. if($dateArr[3] == 7) { $whichsat = floor(($dateArr[2] - 1)/7) + 1; return($whichsat == 3); } else { return(FALSE); } } function nextThirdSaturday() { // Returns a date string for the next third Saturday of the month. // First, what is the date now? $today = todayArray(); // Move forward to the next Saturday (which could be today). $newdate = nextSaturday($today); // Find the next third Saturday (which could be today). while(!isThirdSaturday($newdate)) { // Go forward a week. $newdate = addDays($newdate, 7); } // Now format that in a nice way. return(date('F j, Y', mktime(12, 0, 0, $newdate[1], $newdate[2], $newdate[0]))); } ?>
Monthly meet and greet for Indiana-area AB/DLs! Check out our Google group for discussion and announcements.