From 5d10b7589c5f2ddc5f961e73fc6815bbc836c938 Mon Sep 17 00:00:00 2001 From: Jeremy Shipman Date: Mon, 14 Jan 2008 03:34:47 +0000 Subject: [PATCH] Fixed date ranges for archive blogs --- code/BlogHolder.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/code/BlogHolder.php b/code/BlogHolder.php index 3c618fd..b206b9b 100644 --- a/code/BlogHolder.php +++ b/code/BlogHolder.php @@ -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'"; } } }