Revision: 2699
          https://sourceforge.net/p/mrbs/code/2699/
Author:   cimorrison
Date:     2013-02-15 09:04:07 +0000 (Fri, 15 Feb 2013)
Log Message:
-----------
Fixed bug causing slots to be described as "n days, 24 hours" instead of "n+1 
days".   See SF bugs #236 part (1).

Modified Paths:
--------------
    mrbs/trunk/web/js/edit_entry.js.php

Modified: mrbs/trunk/web/js/edit_entry.js.php
===================================================================
--- mrbs/trunk/web/js/edit_entry.js.php 2013-02-15 08:31:05 UTC (rev 2698)
+++ mrbs/trunk/web/js/edit_entry.js.php 2013-02-15 09:04:07 UTC (rev 2699)
@@ -697,24 +697,24 @@
   var text = '';
   var currentArea = $('#area').data('current');
   var enablePeriods = areaConfig('enable_periods');
+  var durDays;
 
   durUnits = (enablePeriods) ? '<?php echo "periods" ?>' : '<?php echo 
"minutes" ?>';
   duration = to - from;
   duration = Math.floor((to - from) / 60);
-    
-  if (duration < 0)
+  
+  <?php
+  // Adjust the days and duration so that 0 <= duration < 24*60.    If we're 
using
+  // periods then if necessary add/subtract multiples of the number of periods 
in
+  // a day
+  ?>
+  durDays = Math.floor(duration/(24*60));
+  if (durDays !== 0)
   {
-    days--;
-    if (enablePeriods)
-    {
-      duration += $('#rooms' + currentArea).find('option').length;  <?php // 
add a day's worth of periods ?>
-    }
-    else
-    {
-      duration += 24*60;  <?php // add 24 hours (duration is now in minutes)  
?>
-    }
+    days += durDays;
+    duration -= durDays * ((enablePeriods) ? $('#rooms' + 
currentArea).find('option').length : 24*60);
   }
-      
+  
   if (enablePeriods)
   {
     duration++;  <?php // a period is a period rather than a point ?>
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to