cvs: php4 /pear/Date Calc.php

From: Date: Mon, 20 Aug 2001 20:28:22 +0000
Subject: cvs: php4 /pear/Date Calc.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-592@lists.php.net to get a copy of this message
yavo Mon Aug 20 16:28:22 2001 EDT Modified files: /php4/pear/Date Calc.php Log: Added a function getMonthFromFullName to return a month number from a month name. Index: php4/pear/Date/Calc.php diff -u php4/pear/Date/Calc.php:1.11 php4/pear/Date/Calc.php:1.12 --- php4/pear/Date/Calc.php:1.11 Tue Dec 12 09:58:03 2000 +++ php4/pear/Date/Calc.php Mon Aug 20 16:28:22 2001 @@ -1520,7 +1520,30 @@ return substr($weekday_names[$weekday],0,$length); - } // end func getWeekdayFullname + } // end func getWeekdayFullname + + /** + * Returns the numeric month from the month name or an abreviation + * + * Both August and Aug would return 8 + * + * @param string month name + * @return integer month number + */ + function getMonthFromFullName($month){ + $month = strtolower($month); + $months = array("january"=>1, "february"=>2, "march"=>3, + "april"=>4, "may"=>5, "june"=>6, + "july"=>7, "august"=>8, "september"=>9, + "october"=>10, "november"=>11, "desember"=>12); + while(list($name, $id) = each($months)){ + if(ereg($month, $name)){ + return($id); + } + } + return(0); + } + } // end class Date_calendar

« previous php.pear.cvs (#592) next »