[code]
class dd{
}
function getPrevDate(&$d) {
$ret = &new dd();
if ($d->month == 1 && $d->day == 1) {
$ret->day = 31;
$ret->month = 12;
$ret->year = $d->year - 1;
return $ret;
}
if ($d->month == 3) {
if ($d->day == 1 && date("L", mktime(0, 0, 0, $d->month, $d->day, $d->year)) == 1)
$ret->day = 29;
else if ($d->day == 1)
$ret->day = 28;
$ret->month = 2;
$ret->year = $d->year ;
return $ret;
}
if ($d->day == 1) {
if ($d->month == 5 || $d->month == 7 || $d->month == 8 || $d->month == 10 || $d->month == 12)
$ret->day = 30;
else
$ret->day = 31;
$ret->month = $d->month - 1;
$ret->year = $d->year;
return $ret;
}
$ret->day = $d->day - 1;
$ret->month = $d->month;
$ret->year = $d->year;
return $ret;
}
[/code]