Revision: 1299
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1299&view=rev
Author:   cimorrison
Date:     2010-02-17 23:15:06 +0000 (Wed, 17 Feb 2010)

Log Message:
-----------
Fixed a bug which meant that n-weekly repeats weren't being calculated properly 
when more than one repeat day was checked.

Modified Paths:
--------------
    mrbs/trunk/web/mrbs_sql.inc

Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2010-02-17 20:59:15 UTC (rev 1298)
+++ mrbs/trunk/web/mrbs_sql.inc 2010-02-17 23:15:06 UTC (rev 1299)
@@ -411,7 +411,6 @@
   $week_num = 0;
   $start_day = date('w', $time);
   $start_dom = $day;  // the starting day of the month
-  $cur_day = $start_day;
 
   $entrys = array();
   for ($i = 0; $i < $max_ittr; $i++)
@@ -427,7 +426,7 @@
     switch($rep_type)
     {
       case REP_DAILY:
-        $day += 1;
+        $day++;
         break;
       
       case REP_WEEKLY:
@@ -435,23 +434,30 @@
       case REP_N_WEEKLY:
         $j = $cur_day = date("w", $entrys[$i]);
         // Skip over days of the week which are not enabled:
-        while (($j = ($j + 1) % 7) != $cur_day && !$rep_opt[$j])
+        do
         {
-          $day += 1;
+          $day++;
+          $j = ($j + 1) % 7;
+          // If we've got back to the beginning of the week, then skip
+          // over the weeks we've got to miss out (eg miss out one week
+          // if we're repeating every two weeks)
+          if ($j == $start_day)
+          {
+            $day += 7 * ($rep_num_weeks - 1);
+          }
         }
-
-        $day += 1 + (7 * ($rep_num_weeks - 1));
+        while (($j != $cur_day) && !$rep_opt[$j]);
         break;
       
       case REP_MONTHLY:
       case REP_YEARLY:
         if ($rep_type == REP_MONTHLY)
         {
-          $month += 1;
+          $month++;
         }
         else
         {
-          $year += 1;
+          $year++;
         }
         // Make sure the month and year are valid, so
         // that we can check the days with checkdate()


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Download Intel&reg; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs 
proactively, and fine-tune applications for parallel performance. 
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to