aboutsummaryrefslogtreecommitdiffstats
path: root/month.php
diff options
context:
space:
mode:
authorjwangen <jwangen>2002-11-01 19:13:45 +0000
committerjwangen <jwangen>2002-11-01 19:13:45 +0000
commit405e76ca59ed46f0af3a7e518c62cda469c1519c (patch)
treeb03204b6adb66e16034206c5fafccf531bb6cd76 /month.php
parentb498e8c70d7ee2f4dd7b5b3afd20a2c808cc4045 (diff)
downloadphpicalendar-405e76ca59ed46f0af3a7e518c62cda469c1519c.tar.gz
phpicalendar-405e76ca59ed46f0af3a7e518c62cda469c1519c.tar.bz2
phpicalendar-405e76ca59ed46f0af3a7e518c62cda469c1519c.zip
Fixed bug in month where next month and previous month wasn't working for
certain days of certain months.
Diffstat (limited to 'month.php')
-rw-r--r--month.php21
1 files changed, 19 insertions, 2 deletions
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";

© 2014-2024 Faster IT GmbH | imprint | privacy policy