Skip to content

Instantly share code, notes, and snippets.

@freejoe76
Created May 16, 2012 05:07
Show Gist options
  • Save freejoe76/2707615 to your computer and use it in GitHub Desktop.
Save freejoe76/2707615 to your computer and use it in GitHub Desktop.
Build a list of a particular holiday for its future dates
<?php
class day
{
public $day, $days, $year, $verbose;
function mothers($limit = 101)
{
// Return an array of the future mothers days
// for the next hundred years.
// Mother's Day: The second Sunday in May.
// Each May. For a bajillion years.
$limit = $this->year + $limit;
$days = Array();
for ( $year = $this->year - 1; $year <= $limit; $year++ ):
$month = 5;
$time = mktime(0, 0, 0, $month, 1, $year);
$date = strtotime('second Sunday', $time);
if ( $this->verbose == TRUE ) echo ' ' . date('m/d/Y', $date);
$days[$year] = $date;
endfor;
return $days;
}
function __construct($type = 'mothers', $verbose = FALSE)
{
$this->day = time();
$this->year = date('Y');
$this->verbose = $verbose;
echo $type;
// We take the holiday we're using, and we generate
// a list of the future days for that holiday.
switch ( $type ):
case 'mothers':
// We're whitelisting what gets passed
// here, so this eval is okay.
eval("\$days = \$this->" . $type . "();");
default:
return false;
endswitch;
$this->days = $days;
}
function is_this_year()
{
}
function is_yet_to_come()
{
}
}
$verbose = TRUE;
$day = new day('mothers', $verbose);
echo $day->days[2012];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment