From 405e76ca59ed46f0af3a7e518c62cda469c1519c Mon Sep 17 00:00:00 2001 From: jwangen Date: Fri, 1 Nov 2002 19:13:45 +0000 Subject: Fixed bug in month where next month and previous month wasn't working for certain days of certain months. --- month.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'month.php') diff --git a/month.php b/month.php index c47e9fa..3d0fed9 100644 --- a/month.php +++ b/month.php @@ -14,8 +14,25 @@ $tomorrows_date = date( "Ymd", strtotime("+1 day", $unix_time)); $yesterdays_date = date( "Ymd", strtotime("-1 day", $unix_time)); $date = mktime(0,0,0,"$this_month","$this_day","$this_year"); - $next_month = date("Ymd", DateAdd ("m", "1", $date)); - $prev_month = date("Ymd", DateAdd ("m", "-1", $date)); + + // find out next month + $next_month_month = ($this_month+1 == '13') ? '1' : ($this_month+1); + $next_month_day = $this_day; + $next_month_year = ($next_month_month == '1') ? ($this_year+1) : $this_year; + while (!checkdate($next_month_month,$next_month_day,$next_month_year)) $next_month_day--; + $next_month_time = mktime(0,0,0,$next_month_month,$next_month_day,$next_month_year); + + // find out last month + $prev_month_month = ($this_month-1 == '0') ? '12' : ($this_month-1); + $prev_month_day = $this_day; + $prev_month_year = ($prev_month_month == '12') ? ($this_year-1) : $this_year; + while (!checkdate($prev_month_month,$prev_month_day,$prev_month_year)) $prev_month_day--; + $prev_month_time = mktime(0,0,0,$prev_month_month,$prev_month_day,$prev_month_year); + + + $next_month = date("Ymd", $next_month_time); + $prev_month = date("Ymd", $prev_month_time); + $display_month = localizeDate ($dateFormat_month, $date); $parse_month = date ("Ym", $date); $first_of_month = $this_year.$this_month."01"; -- cgit v1.2.3