aboutsummaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorJason Oster <parasytic@users.sourceforge.net>2009-12-29 16:08:55 +0000
committerJason Oster <parasytic@users.sourceforge.net>2009-12-29 16:08:55 +0000
commitb7d6d1d72222686975862269069763819bbfdb6d (patch)
tree38236337aab75951e95f4065edcaea7d30cb39d7 /functions
parent5a5cdd4064f4c7ca15a861d34271dbde4d3c094b (diff)
downloadphpicalendar-b7d6d1d72222686975862269069763819bbfdb6d.tar.gz
phpicalendar-b7d6d1d72222686975862269069763819bbfdb6d.tar.bz2
phpicalendar-b7d6d1d72222686975862269069763819bbfdb6d.zip
Fixed recurring events across multiple versions of PHP; thanks to Len and gueba!
Diffstat (limited to 'functions')
-rw-r--r--functions/parse/recur_functions.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/functions/parse/recur_functions.php b/functions/parse/recur_functions.php
index 89d39b2..08b2bb1 100644
--- a/functions/parse/recur_functions.php
+++ b/functions/parse/recur_functions.php
@@ -140,7 +140,7 @@ function expand_byday($time){
if(empty($byweekno)){
$week_arr = array(1,2,3,4,5);
if(isset($byday_arr[2]) && $byday_arr[2] !='') $week_arr = array($byday_arr[2]);
- $month_start = strtotime(date("Ym00",$time));
+ $month_start = strtotime(date("Ym01",$time)) - (24 * 60 * 60);
$month_end = strtotime(date("Ymt",$time))+ (36 * 60 * 60);
if($freq_type == 'year' && empty($bymonth)){
$month_start = mktime(12,0,0,1,0,$year);
@@ -149,7 +149,13 @@ function expand_byday($time){
foreach($week_arr as $week){
#echo "<pre>$summary ".$byday_arr[1].$week.$on_day." st:".date("Ymd",$month_start)." t:".date("Ymd",$time)."\n";
if($byday_arr[1] == '-') $next_date_time = strtotime($byday_arr[1].$week.$on_day,$month_end);
- else $next_date_time = strtotime($byday_arr[1].$week.$on_day,$month_start);
+ else {
+ # we need this special offset in case the event day coincides with the month start day
+ # eg: month starts on a Sunday, our event is the Nth Sunday of the month... without this
+ # special offset, the event will be added to the (N+1)th Sunday of the month
+ $special_offset = ($month_start_day == $on_day) ? (24 * 60 * 60) : 0;
+ $next_date_time = strtotime($byday_arr[1] . $week . $on_day, ($month_start + $special_offset));
+ }
# check that we're still in the same month
if (date("m",$next_date_time) == date("m",$time) ) $times[] = $next_date_time;
}

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