public function toDays(AnDate $date = null)
    {
        $year = isset($date) ? $date->year  : $this->year;
        $month = isset($date) ? $date->month : $this->month;
        $day = isset($date) ? $date->day   : $this->day;

        $century = (int) substr($year, 0, 2);
        $year = (int) substr($year, 2, 2);

        if ($month > 2) {
            $month -= 3;
        } else {
            $month += 9;
            if ($year) {
                $year--;
            } else {
                $year = 99;
                $century--;
            }
        }

        return (
            floor((146097 * $century) / 4) +
            floor((1461 * $year) / 4) +
            floor((153 * $month + 2) / 5) +
            $day + 1721119);
    }
public function toDays(AnDate $date = null)
    {
        $year = isset($date) ? $date->year  : $this->year;
        $month = isset($date) ? $date->month : $this->month;
        $day = isset($date) ? $date->day   : $this->day;

        $century = (int) substr($year, 0, 2);
        $year = (int) substr($year, 2, 2);

        if ($month > 2) {
            $month -= 3;
        } else {
            $month += 9;
            if ($year) {
                $year--;
            } else {
                $year = 99;
                $century--;
            }
        }

        return (
            floor((146097 * $century) / 4) +
            floor((1461 * $year) / 4) +
            floor((153 * $month + 2) / 5) +
            $day + 1721119);
    }
public function toDays ( AnDate $ date = null ) { $ year = isset ( $ date ) ? $ date -> year : $ this -> year ; $ month = isset ( $ date ) ? $ date -> month : $ this -> month ; $ day = isset ( $ date ) ? $ date -> day : $ this -> day ; $ century = ( int ) substr ( $ year , 0 , 2 ) ; $ year = ( int ) substr ( $ year , 2 , 2 ) ; if ( $ month > 2 ) { $ month -= 3 ; } else { $ month += 9 ; if ( $ year ) { $ year -- ; } else { $ year = 99 ; $ century -- ; } } return ( floor ( ( 146097 * $ century ) / 4 ) + floor ( ( 1461 * $ year ) / 4 ) + floor ( ( 153 * $ month + 2 ) / 5 ) + $ day + 1721119 ) ; }
Converts a date to number of days since a distant unspecified epoch

@param int    the day of the month
@param int    the month
@param int    the year.  Use the complete year instead of the abbreviated
version. E.g. use 2005, not 05. Do not add leading 0's for years prior to
1000.

@return integer  the number of days since the epoch
Converts a date to number of days since a distant unspecified epoch