Fixed date ranges for archive blogs

This commit is contained in:
Jeremy Shipman 2008-01-14 03:34:47 +00:00
parent 3505c315c5
commit 5d10b7589c
1 changed files with 6 additions and 3 deletions

View File

@ -69,10 +69,13 @@ class BlogHolder extends Page {
$year = Director::urlParam('Action');
$month = Director::urlParam('ID');
if(is_numeric($month) && is_numeric($month)){
$dateCheck = "AND `BlogEntry`.Date BETWEEN '$year-$month-1' AND '$year-$month-31'";
if(is_numeric($month) && is_numeric($month)){
$nextyear = ($month==12) ? $year + 1 : $year;
$nextmonth = $month % 12 + 1;
$dateCheck = "AND `BlogEntry`.Date BETWEEN '$year-$month-1' AND '$nextyear-$nextmonth-1'";
} else if(isset($year)){
$dateCheck = "AND `BlogEntry`.Date BETWEEN '$year-1-1' AND '$year-12-31'";
$nextyear = $year + 1;
$dateCheck = "AND `BlogEntry`.Date BETWEEN '$year-1-1' AND '".$nextyear."-1-1'";
}
}
}