cvs: php4 /pear/Date Calc.php

From: Date: Mon, 16 Oct 2000 14:24:50 +0000
Subject: cvs: php4 /pear/Date Calc.php
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2072@lists.php.net to get a copy of this message
mohrt Mon Oct 16 07:24:50 2000 EDT Modified files: /php4/pear/Date Calc.php Log: changed function names to studlyCaps for PEAR code consistancy Index: php4/pear/Date/Calc.php diff -u php4/pear/Date/Calc.php:1.2 php4/pear/Date/Calc.php:1.3 --- php4/pear/Date/Calc.php:1.2 Sun Oct 15 17:19:37 2000 +++ php4/pear/Date/Calc.php Mon Oct 16 07:24:50 2000 @@ -19,7 +19,7 @@ * * @access public * - * @version 1.0.2 + * @version 1.0.3 * @author Monte Ohrt <monte@ispi.net> */ @@ -52,11 +52,11 @@ * @return string the current date in specified format */ - function date_now($format="%Y%m%d") + function dateNow($format="%Y%m%d") { return(strftime($format,time())); - } // end func date_now + } // end func dateNow /** * Returns true for valid date, false for invalid date. @@ -72,7 +72,7 @@ * @return boolean true/false */ - function is_valid_date($year, $month, $day) + function isValidDate($year, $month, $day) { if(empty($year) || empty($month) || empty($day)) @@ -90,18 +90,18 @@ return false; if($month < 1 || $month > 12) return false; - if($day < 1 || $day > 31 || $day > $this->days_in_month($month)) + if($day < 1 || $day > 31 || $day > $this->daysInMonth($month)) return false; return true; - } // end func is_valid_date + } // end func isValidDate - function is_leap_year($year="") + function isLeapYear($year="") { if(empty($year)) - $year = $this->date_now("%Y"); + $year = $this->dateNow("%Y"); if(strlen($year) != 4) return false; @@ -111,7 +111,7 @@ return (($year % 4 == 0 && $year % 100 != 0) || $year % 400 == 0); - } // end func is_leap_year + } // end func isLeapYear /** * Determines if given date is a future date from now. @@ -127,11 +127,11 @@ * @return boolean true/false */ - function is_future_date($year,$month,$day) + function isFutureDate($year,$month,$day) { - $this_year = $this->date_now("%Y"); - $this_month = $this->date_now("%m"); - $this_day = $this->date_now("%d"); + $this_year = $this->dateNow("%Y"); + $this_month = $this->dateNow("%m"); + $this_day = $this->dateNow("%d"); if($year > $this_year) @@ -145,7 +145,7 @@ return false; - } // end func is_future_date + } // end func isFutureDate /** * Determines if given date is a past date from now. @@ -161,11 +161,11 @@ * @return boolean true/false */ - function is_past_date($year,$month,$day) + function isPastDate($year,$month,$day) { - $this_year = $this->date_now("%Y"); - $this_month = $this->date_now("%m"); - $this_day = $this->date_now("%d"); + $this_year = $this->dateNow("%Y"); + $this_month = $this->dateNow("%m"); + $this_day = $this->dateNow("%d"); if($year < $this_year) @@ -179,7 +179,7 @@ return false; - } // end func is_past_date + } // end func isPastDate /** * Returns day of week for given date, 0=Sunday @@ -195,14 +195,14 @@ * @return int $weekday_number */ - function day_of_week($year="",$month="",$day="") + function dayOfWeek($year="",$month="",$day="") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } if($month > 2) @@ -223,7 +223,7 @@ return $weekday_number; - } // end func day_of_week + } // end func dayOfWeek /** * Returns week of the year, first Sunday is first day of first week @@ -239,13 +239,13 @@ * @return integer $week_number */ - function week_of_year($year,$month,$day) + function weekOfYear($year,$month,$day) { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } $week_year = $year - 1501; @@ -253,11 +253,11 @@ - floor($week_year / 100) + floor(($week_year - 300) / 400); $week_number = - floor(($this->julian_date($year,$month,$day) + floor(($week_day + 4) % 7)) / 7); + floor(($this->julianDate($year,$month,$day) + floor(($week_day + 4) % 7)) / 7); return $week_number; - } // end func week_of_year + } // end func weekOfYear /** * Returns number of days since 31 December of year before given date. @@ -273,25 +273,25 @@ * @return int $julian */ - function julian_date($year="",$month="",$day="") + function julianDate($year="",$month="",$day="") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } $days = array(0,31,59,90,120,151,181,212,243,273,304,334); $julian = ($days[$month - 1] + $day); - if($month > 2 && $this->is_leap_year($year)) + if($month > 2 && $this->isLeapYear($year)) $julian++; return($julian); - } // end func julian_date + } // end func julianDate /** * Returns quarter of the year for given date @@ -307,20 +307,20 @@ * @return int $year_quarter */ - function quarter_of_year($year="",$month="",$day="") + function quarterOfYear($year="",$month="",$day="") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } $year_quarter = (intval(($month - 1) / 3 + 1)); return $year_quarter; - } // end func quarter_of_year + } // end func quarterOfYear /** * Returns date of begin of next month of given date. @@ -337,13 +337,13 @@ * @return string date in given format */ - function begin_of_next_month($year="",$month="",$day="",$format="%Y%m%d") + function beginOfNextMonth($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } if($month < 12) @@ -358,9 +358,9 @@ $day=1; } - return $this->date_format($year,$month,$day,$format); + return $this->dateFormat($year,$month,$day,$format); - } // end func begin_of_next_month + } // end func beginOfNextMonth /** * Returns date of the last day of next month of given date. @@ -377,16 +377,16 @@ * @return string date in given format */ - function end_of_next_month($year="",$month="",$day="",$format="%Y%m%d") + function endOfNextMonth($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $day = $this->days_in_month($month); + $day = $this->daysInMonth($month); if($month < 12) { @@ -398,9 +398,9 @@ $month=1; } - return $this->date_format($year,$month,$day,$format); + return $this->dateFormat($year,$month,$day,$format); - } // end func end_of_next_month + } // end func endOfNextMonth /** * Returns date of the first day of previous month of given date. @@ -417,13 +417,13 @@ * @return string date in given format */ - function begin_of_prev_month($year="",$month="",$day="",$format="%Y%m%d") + function beginOfPrevMonth($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } if($month > 1) @@ -438,9 +438,9 @@ $day=1; } - return $this->date_format($year,$month,$day,$format); + return $this->dateFormat($year,$month,$day,$format); - } // end func begin_of_prev_month + } // end func beginOfPrevMonth /** * Returns date of the last day of previous month for given date. @@ -457,16 +457,16 @@ * @return string date in given format */ - function end_of_prev_month($year="",$month="",$day="",$format="%Y%m%d") + function endOfPrevMonth($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $day = $this->days_in_month($month); + $day = $this->daysInMonth($month); if($month > 1) { @@ -478,9 +478,9 @@ $month=12; } - return $this->date_format($year,$month,$day,$format); + return $this->dateFormat($year,$month,$day,$format); - } // end func end_of_prev_month + } // end func endOfPrevMonth /** * Returns date of the next weekday of given date, @@ -498,27 +498,27 @@ * @return string date in given format */ - function next_weekday($year="",$month="",$day="",$format="%Y%m%d") + function nextWeekday($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $days = $this->date_to_days($year,$month,$day); + $days = $this->dateToDays($year,$month,$day); - if($this->day_of_week($year,$month,$day) == 5) + if($this->dayOfWeek($year,$month,$day) == 5) $days += 3; - elseif($this->day_of_week($year,$month,$day) == 6) + elseif($this->dayOfWeek($year,$month,$day) == 6) $days += 2; else $days += 1; - return($this->days_to_date($days,$format)); + return($this->daysToDate($days,$format)); - } // end func next_weekday + } // end func nextWeekday /** * Returns date of the previous weekday, @@ -536,27 +536,27 @@ * @return string date in given format */ - function prev_weekday($year="",$month="",$day="",$format="%Y%m%d") + function prevWeekday($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $days = $this->date_to_days($year,$month,$day); + $days = $this->dateToDays($year,$month,$day); - if($this->day_of_week($year,$month,$day) == 1) + if($this->dayOfWeek($year,$month,$day) == 1) $days -= 3; - elseif($this->day_of_week($year,$month,$day) == 0) + elseif($this->dayOfWeek($year,$month,$day) == 0) $days -= 2; else $days -= 1; - return($this->days_to_date($days,$format)); + return($this->daysToDate($days,$format)); - } // end func prev_weekday + } // end func prevWeekday /** * Returns date of day after given date. @@ -573,20 +573,20 @@ * @return string date in given format */ - function next_day($year="",$month="",$day="",$format="%Y%m%d") + function nextDay($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $days = $this->date_to_days($year,$month,$day); + $days = $this->dateToDays($year,$month,$day); - return($this->days_to_date($days + 1,$format)); + return($this->daysToDate($days + 1,$format)); - } // end func next_day + } // end func nextDay /** * Returns date of day before given date. @@ -603,20 +603,20 @@ * @return string date in given format */ - function prev_day($year="",$month="",$day="",$format="%Y%m%d") + function prevDay($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $days = $this->date_to_days($year,$month,$day); + $days = $this->dateToDays($year,$month,$day); - return($this->days_to_date($days - 1,$format)); + return($this->daysToDate($days - 1,$format)); - } // end func prev_day + } // end func prevDay /** * Sets century for 2 digit year. @@ -631,7 +631,7 @@ * @return string 4 digit year */ - function default_century($year) + function defaultCentury($year) { if(strlen($year) == 1) $year = "0$year"; @@ -640,7 +640,7 @@ else return( "20$year" ); - } // end func default_century + } // end func defaultCentury /** * Returns number of days between two given dates. @@ -660,17 +660,17 @@ * -1 if there is an error. */ - function date_diff($year1,$month1,$day1,$year2,$month2,$day2) + function dateDiff($year1,$month1,$day1,$year2,$month2,$day2) { - if(!$this->is_valid_date($year1,$month1,$day1)) + if(!$this->isValidDate($year1,$month1,$day1)) return -1; - if(!$this->is_valid_date($year2,$month2,$day2)) + if(!$this->isValidDate($year2,$month2,$day2)) return -1; - return(abs(($this->date_to_days($year1,$month1,$day1)) - - ($this->date_to_days($year2,$month2,$day2)))); + return(abs(($this->dateToDays($year1,$month1,$day1)) + - ($this->dateToDays($year2,$month2,$day2)))); - } // end func date_diff + } // end func dateDiff /** * Find the number of days in the given month. @@ -684,14 +684,14 @@ * @return int number of days */ - function days_in_month($month="") + function daysInMonth($month="") { if(empty($month)) - $month = $this->date_now("%m"); + $month = $this->dateNow("%m"); if($month == 2) { - if($this->is_leap_year($year)) + if($this->isLeapYear($year)) return 29; else return 28; @@ -701,7 +701,7 @@ else return 31; - } // end func days_in_month + } // end func daysInMonth /** * Find the day of the week for the first of the month of given date. @@ -716,17 +716,17 @@ * @return int number of weekday for the first day, 0=Sunday */ - function first_of_month_weekday($year="",$month="") + function firstOfMonthWeekday($year="",$month="") { if(empty($year) || empty($month)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); } - return($this->day_of_week($year,$month,"01")); + return($this->dayOfWeek($year,$month,"01")); - } // end func first_of_month_weekday + } // end func firstOfMonthWeekday /** * Return date of first day of month of given date. @@ -742,17 +742,17 @@ * @return string date in given format */ - function begin_of_month($year="",$month="",$format="%Y%m%d") + function beginOfMonth($year="",$month="",$format="%Y%m%d") { if(empty($year) || empty($month)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); } - return($this->date_format($year,$month,"01",$format)); + return($this->dateFormat($year,$month,"01",$format)); - } // end of func begin_of_month + } // end of func beginOfMonth /** * Find the month day of the beginning of week for given date, @@ -770,23 +770,23 @@ * @return string date in given format */ - function begin_of_week($year="",$month="",$day="",$format="%Y%m%d") + function beginOfWeek($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $this_weekday = $this->day_of_week($year,$month,$day); + $this_weekday = $this->dayOfWeek($year,$month,$day); - $begin_of_week = ($this->date_to_days($year,$month,$day) + $beginOfWeek = ($this->dateToDays($year,$month,$day) - ($this_weekday - $this->begin_weekday)); - return($this->days_to_date($begin_of_week,$format)); + return($this->daysToDate($beginOfWeek,$format)); - } // end of func begin_of_week + } // end of func beginOfWeek /** * Find the month day of the end of week for given date, @@ -805,23 +805,23 @@ * @return string date in given format */ - function end_of_week($year="",$month="",$day="",$format="%Y%m%d") + function endOfWeek($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $this_weekday = $this->day_of_week($year,$month,$day); + $this_weekday = $this->dayOfWeek($year,$month,$day); - $last_day_of_week = ($this->date_to_days($year,$month,$day) + $last_dayOfWeek = ($this->dateToDays($year,$month,$day) + (6 - $this_weekday + $this->begin_weekday)); - return($this->days_to_date($last_day_of_week,$format)); + return($this->daysToDate($last_dayOfWeek,$format)); - } // end func end_of_week + } // end func endOfWeek /** * Find the month day of the beginning of week after given date, @@ -839,29 +839,29 @@ * @return string date in given format */ - function begin_of_next_week($year="",$month="",$day="",$format="%Y%m%d") + function beginOfNextWeek($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $date = $this->days_to_date($this->date_to_days($year,$month,$day+7),"%Y%m%d"); + $date = $this->daysToDate($this->dateToDays($year,$month,$day+7),"%Y%m%d"); $next_week_year = substr($date,0,4); $next_week_month = substr($date,4,2); $next_week_day = substr($date,6,2); - $this_weekday = $this->day_of_week($next_week_year,$next_week_month,$next_week_day); + $this_weekday = $this->dayOfWeek($next_week_year,$next_week_month,$next_week_day); - $begin_of_week = ($this->date_to_days($next_week_year,$next_week_month,$next_week_day) + $beginOfWeek = ($this->dateToDays($next_week_year,$next_week_month,$next_week_day) - ($this_weekday - $this->begin_weekday)); - return($this->days_to_date($begin_of_week,$format)); + return($this->daysToDate($beginOfWeek,$format)); - } // end func begin_of_next_week + } // end func beginOfNextWeek /** * Find the month day of the beginning of week before given date, @@ -879,29 +879,29 @@ * @return string date in given format */ - function begin_of_prev_week($year="",$month="",$day="",$format="%Y%m%d") + function beginOfPrevWeek($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } - $date = $this->days_to_date($this->date_to_days($year,$month,$day-7),"%Y%m%d"); + $date = $this->daysToDate($this->dateToDays($year,$month,$day-7),"%Y%m%d"); $next_week_year = substr($date,0,4); $next_week_month = substr($date,4,2); $next_week_day = substr($date,6,2); - $this_weekday = $this->day_of_week($next_week_year,$next_week_month,$next_week_day); + $this_weekday = $this->dayOfWeek($next_week_year,$next_week_month,$next_week_day); - $begin_of_week = ($this->date_to_days($next_week_year,$next_week_month,$next_week_day) + $beginOfWeek = ($this->dateToDays($next_week_year,$next_week_month,$next_week_day) - ($this_weekday - $this->begin_weekday)); - return($this->days_to_date($begin_of_week,$format)); + return($this->daysToDate($beginOfWeek,$format)); - } // end func begin_of_prev_week + } // end func beginOfPrevWeek /** * Return an array with days in week @@ -918,30 +918,30 @@ * @return array $week[$weekday] */ - function get_calendar_week($year="",$month="",$day="",$format="%Y%m%d") + function getCalendarWeek($year="",$month="",$day="",$format="%Y%m%d") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } $week_array = array(); // date for the column of week - $curr_day = ($this->date_to_days($year,$month,$day) - - (($this->day_of_week($year,$month,$day) - $this->begin_weekday))); + $curr_day = ($this->dateToDays($year,$month,$day) + - (($this->dayOfWeek($year,$month,$day) - $this->begin_weekday))); for($counter=0; $counter <= 6; $counter++) { - $week_array[$counter] = $this->days_to_date($curr_day,$format); + $week_array[$counter] = $this->daysToDate($curr_day,$format); $curr_day++; } return $week_array; - } // end func get_calendar_week + } // end func getCalendarWeek /** * Return a set of arrays to construct a calendar month for @@ -958,35 +958,35 @@ * @return array $month[$row][$col] */ - function get_calendar_month($year="",$month="",$format="%Y%m%d") + function getCalendarMonth($year="",$month="",$format="%Y%m%d") { if(empty($year) || empty($month)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); } $month_array = array(); // date for the first row, first column of calendar month - $curr_day = ($this->date_to_days($year,$month,"01") - - $this->first_of_month_weekday($year,$month,"01") + $this->begin_weekday); + $curr_day = ($this->dateToDays($year,$month,"01") + - $this->firstOfMonthWeekday($year,$month,"01") + $this->begin_weekday); // number of days in this month - $days_in_month = $this->days_in_month($month); + $daysInMonth = $this->daysInMonth($month); for($row_counter=0; $row_counter <= 5; $row_counter++) { for($column_counter=0; $column_counter <= 6; $column_counter++) { - $month_array[$row_counter][$column_counter] = $this->days_to_date($curr_day,$format); + $month_array[$row_counter][$column_counter] = $this->daysToDate($curr_day,$format); $curr_day++; } } return $month_array; - } // end func get_calendar_month + } // end func getCalendarMonth /** * Return a set of arrays to construct a calendar year for @@ -1002,17 +1002,17 @@ * @return array $year[$month][$row][$col] */ - function get_calendar_year($year="",$format="%Y%m%d") + function getCalendarYear($year="",$format="%Y%m%d") { if(empty($year)) - $year = $this->date_now("%Y"); + $year = $this->dateNow("%Y"); $year_array = array(); for($curr_month=0; $curr_month <=11; $curr_month++) { - $year_array[$curr_month] = $this->get_calendar_month($year,sprintf("%02d",$curr_month+1),$format); + $year_array[$curr_month] = $this->getCalendarMonth($year,sprintf("%02d",$curr_month+1),$format); /* for ($x=0; $x< count($year_array[$curr_month]); $x++) { @@ -1025,7 +1025,7 @@ return $year_array; - } // end func get_calendar_year + } // end func getCalendarYear /** * Converts a date to number of days since a @@ -1042,7 +1042,7 @@ * @return integer number of days */ - function date_to_days($year,$month,$day) + function dateToDays($year,$month,$day) { $century = substr($year,0,2); @@ -1067,7 +1067,7 @@ floor(( 153 * $month + 2) / 5 ) + $day + 1721119); - } // end func date_to_days + } // end func dateToDays /** * Converts number of days to a distant unspecified epoch. @@ -1082,7 +1082,7 @@ * @return string date in specified format */ - function days_to_date($days,$format="%Y%m%d") + function daysToDate($days,$format="%Y%m%d") { $days -= 1721119; @@ -1113,16 +1113,16 @@ $century = sprintf("%02d",$century); $year = sprintf("%02d",$year); - return($this->date_format($century.$year,$month,$day,$format)); + return($this->dateFormat($century.$year,$month,$day,$format)); - } // end func days_to_date + } // end func daysToDate /** * Calculates the date of the Nth weekday of the month, * such as the second Saturday of January 2000. * * @param string occurance: 1=first, 2=second, 3=third, etc. - * @param string day_of_week: 0=Sunday, 1=Monday, etc. + * @param string dayOfWeek: 0=Sunday, 1=Monday, etc. * @param string year in format CCYY * @param string month in format MM * @param string format for returned date @@ -1134,23 +1134,23 @@ * @return string date in given format */ - function N_weekday_of_month($occurance,$day_of_week,$year,$month,$format="%Y%m%d") { + function NWeekdayOfMonth($occurance,$dayOfWeek,$year,$month,$format="%Y%m%d") { $year = sprintf("%04d",$year); $month = sprintf("%02d",$month); $DOW1day = sprintf("%02d",(($occurance - 1) * 7 + 1)); - $DOW1 = $this->day_of_week($year,$month,$DOW1day); + $DOW1 = $this->dayOfWeek($year,$month,$DOW1day); $wdate = ($occurance - 1) * 7 + 1 + - (7 + $day_of_week - $DOW1) % 7; + (7 + $dayOfWeek - $DOW1) % 7; - if( $wdate > $this->days_in_month($date)) + if( $wdate > $this->daysInMonth($date)) return -1; else - return($this->date_format($year,$month,$wdate,$format)); + return($this->dateFormat($year,$month,$wdate,$format)); - } // end func N_weekday_of_month + } // end func NWeekdayOfMonth /** * Formats the date in the given format, much like @@ -1170,7 +1170,7 @@ * %E number of days since unspecified epoch (integer) * (%E is useful for passing a date in a URL as * an integer value. Then simply use - * days_to_date() to convert back to a date.) + * daysToDate() to convert back to a date.) * %j day of year (range 001 to 366) * %m month as decimal number (range 1 to 12) * %n newline character (\n) @@ -1193,13 +1193,13 @@ * @return string date in given format */ - function date_format($year,$month,$day,$format) + function dateFormat($year,$month,$day,$format) { - if(!$this->is_valid_date($year,$month,$day)) + if(!$this->isValidDate($year,$month,$day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } $output = ""; @@ -1213,16 +1213,16 @@ switch($nextchar) { case "a": - $output .= $this->get_weekday_abbrname($year,$month,$day); + $output .= $this->getWeekdayAbbrname($year,$month,$day); break; case "A": - $output .= $this->get_weekday_fullname($year,$month,$day); + $output .= $this->getWeekdayFullname($year,$month,$day); break; case "b": - $output .= $this->get_month_abbrname($month); + $output .= $this->getMonthAbbrname($month); break; case "B": - $output .= $this->get_month_fullname($month); + $output .= $this->getMonthFullname($month); break; case "d": $output .= sprintf("%02d",$day); @@ -1231,10 +1231,10 @@ $output .= $day; break; case "E": - $output .= $this->date_to_days($year,$month,$day); + $output .= $this->dateToDays($year,$month,$day); break; case "j": - $output .= $this->julian_date($year,$month,$day); + $output .= $this->julianDate($year,$month,$day); break; case "m": $output .= sprintf("%02d",$month); @@ -1246,10 +1246,10 @@ $output .= "\t"; break; case "w": - $output .= $this->day_of_week($year,$month,$day); + $output .= $this->dayOfWeek($year,$month,$day); break; case "U": - $output .= $this->week_of_year($year,$month,$day); + $output .= $this->weekOfYear($year,$month,$day); break; case "y": $output .= substr($year,2,2); @@ -1272,7 +1272,7 @@ } return $output; - } // end func date_format + } // end func dateFormat /** * Returns the current local year in format CCYY @@ -1284,11 +1284,11 @@ * @return string year in format CCYY */ - function get_year() + function getYear() { - return $this->date_now("%Y"); + return $this->dateNow("%Y"); - } // end func get_year + } // end func getYear /** * Returns the current local month in format MM @@ -1300,11 +1300,11 @@ * @return string month in format MM */ - function get_month() + function getMonth() { - return $this->date_now("%m"); + return $this->dateNow("%m"); - } // end func get_month + } // end func getMonth /** * Returns the current local day in format DD @@ -1316,11 +1316,11 @@ * @return string day in format DD */ - function get_day() + function getDay() { - return $this->date_now("%d"); + return $this->dateNow("%d"); - } // end func get_day + } // end func getDay /** * Returns the full month name for the given month @@ -1334,17 +1334,17 @@ * @return string full month name */ - function get_month_fullname($month) + function getMonthFullname($month) { if(empty($month)) - $month = $this->date_now("%m"); + $month = $this->dateNow("%m"); $month_names = array("January","February","March","April","May","June", "July","August","September","October","November","December"); return $month_names[($month - 1)]; - } // end func get_month_fullname + } // end func getMonthFullname /** * Returns the abbreviated month name for the given month @@ -1359,17 +1359,17 @@ * @return string abbreviated month name */ - function get_month_abbrname($month,$length=3) + function getMonthAbbrname($month,$length=3) { if(empty($month)) - $month = $this->date_now("%m"); + $month = $this->dateNow("%m"); $month_names = array("January","February","March","April","May","June", "July","August","September","October","November","December"); return substr($month_names[($month - 1)],0,$length); - } // end func get_month_abbrname + } // end func getMonthAbbrname /** * Returns the full weekday name for the given date @@ -1385,22 +1385,22 @@ * @return string full month name */ - function get_weekday_fullname($year="",$month="",$day="") + function getWeekdayFullname($year="",$month="",$day="") { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } $weekday_names = array("Sunday","Monday","Tuesday", "Wednesday","Thursday","Friday","Saturday"); - $weekday = $this->day_of_week($year,$month,$day); + $weekday = $this->dayOfWeek($year,$month,$day); return $weekday_names[$weekday]; - } // end func get_weekday_fullname + } // end func getWeekdayFullname /** * Returns the abbreviated weekday name for the given date @@ -1417,23 +1417,23 @@ * @return string full month name */ - function get_weekday_abbrname($year="",$month="",$day="",$length=3) + function getWeekdayAbbrname($year="",$month="",$day="",$length=3) { if(empty($year) || empty($month) || empty($day)) { - $year = $this->date_now("%Y"); - $month = $this->date_now("%m"); - $day = $this->date_now("%d"); + $year = $this->dateNow("%Y"); + $month = $this->dateNow("%m"); + $day = $this->dateNow("%d"); } $weekday_names = array("Sunday","Monday","Tuesday", "Wednesday","Thursday","Friday","Saturday"); - $weekday = $this->day_of_week($year,$month,$date); + $weekday = $this->dayOfWeek($year,$month,$date); return substr($weekday_names[$weekday],0,$length); - } // end func get_weekday_fullname + } // end func getWeekdayFullname } // end class Date_calendar

« previous php.cvs (#2072) next »