Description: Functions used to define a schedule of holidays.
Comment: (none)
Language: PHP Highlight Mode: PHP Last Modified: March 01st, 2009
<?PHPFUNCTION GetTimeStamp($MySqlDate){/*
Take a date in yyyy-mm-dd format and return it to the user in a PHP timestamp
*/$date_array=EXPLODE("-",$MySqlDate);// split the array $var_year=$date_array[0];$var_month=$date_array[1];$var_day=$date_array[2];$var_timestamp=MKTIME(0,0,0,$var_month,$var_day,$var_year);RETURN($var_timestamp);// return it to the user }// End function GetTimeStamp() FUNCTION ordinalDay($ord,$day,$month,$year)// ordinalDay returns date of the $ord $day of $month. // For example ordinalDay(3, 'Sun', 5, 2001) returns the // date of the 3rd Sunday of May (ie. Mother's Day). // // Note: $day must be the 3 char abbr. for the day, as // given by date("D"); // {$firstOfMonth= GetTimeStamp("$year-$month-01");$lastOfMonth=$firstOfMonth+DATE("t",$firstOfMonth)*86400;$dayOccurs=0;FOR($i=$firstOfMonth;$i<$lastOfMonth;$i+=86400){IF(DATE("D",$i)==$day){$dayOccurs++;IF($dayOccurs==$ord){$ordDay=$i;}}}RETURN$ordDay;}// End function ordinalDay() FUNCTION getNextHoliday()// Looks through a lists of defined holidays and tells you which // one is coming up next. // {$year=DATE("Y");CLASS holiday
{VAR$name;VAR$date;VAR$catNum;FUNCTION holiday($name,$date,$catNum)// Contructor to define the details of each holiday as it is created. {$this->name=$name;// Official name of holiday $this->date=$date;// UNIX timestamp of date $this->catNum=$catNum;// category, we used for databases access }}// end class holiday $holidays[]=NEW holiday("Groundhog Day", GetTimeStamp("$year-2-2"),"20");$holidays[]=NEW holiday("Valentine's Day", GetTimeStamp("$year-2-14"),"14");$holidays[]=NEW holiday("St. Patrick's Day", GetTimeStamp("$year-3-17"),"15");$holidays[]=NEW holiday("Easter",EASTER_DATE($year),"16");$holidays[]=NEW holiday("Mother's Day", ordinalDay(2,'Sun',5,$year),"3");$holidays[]=NEW holiday("Father's Day", ordinalDay(3,'Sun',6,$year),"4");$holidays[]=NEW holiday("Independence Day", GetTimeStamp("$year-7-4"),"17");$holidays[]=NEW holiday("Christmas", GetTimeStamp("$year-12-25"),"13");$numHolidays=COUNT($holidays);FOR($i=0;$i<$numHolidays;$i++){IF(DATE("z")>DATE("z",$holidays[$i]->date)&&DATE("z")<=DATE("z",$holidays[$i+1]->date)){$nextHoliday["name"]=$holidays[$i+1]->name;$nextHoliday["dateStamp"]=$holidays[$i+1]->date;$nextHoliday["dateText"]=DATE("F j, Y",$nextHoliday["dateStamp"]);$nextHoliday["num"]=$holidays[$i+1]->catNum;}}RETURN$nextHoliday;}// end function GetNextHoliday $nextHoliday= getNextHoliday();ECHO$nextHoliday["name"]." (".$nextHoliday["dateText"].")";?>
SQL University.net courses meet the most demanding needs of the business world for advanced education
in a cost-effective manner. SQL University.net courses are available immediately for IT professionals
and can be taken without disruption of your workplace schedule or processes.
Compared to traditional travel-based training, SQL University.net saves time and valuable corporate
resources, allowing companies to do more with less. That's our mission, and that's what we deliver.