Revision: 2971
          https://sourceforge.net/p/mrbs/code/2971/
Author:   cimorrison
Date:     2015-01-21 13:34:37 +0000 (Wed, 21 Jan 2015)
Log Message:
-----------
Simplified code

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

Modified: mrbs/trunk/web/functions.inc
===================================================================
--- mrbs/trunk/web/functions.inc        2015-01-21 12:56:18 UTC (rev 2970)
+++ mrbs/trunk/web/functions.inc        2015-01-21 13:34:37 UTC (rev 2971)
@@ -318,10 +318,11 @@
   $endDate = new DateTime();
   $endDate->setTimestamp($end_time);
   
-  // Set both dates to midnight so that we can compare them and get an integral
-  // number of days difference
-  $startDate->modify('00:00');
-  $endDate->modify('00:00');
+  // Set both dates to noon so that we can compare them and get an integral
+  // number of days difference.  Noon also happens to be when periods start,
+  // so will be useful in a moment.
+  $startDate->modify('12:00');  // This won't work in PHP < 5.3.6 (bug)
+  $endDate->modify('12:00');
   
   // Calculate the difference in days
   $interval = $startDate->diff($endDate);
@@ -336,13 +337,12 @@
   else
   {
     // Otherwise we calculate the number of periods on the first day
-    $startDate->modify('12:00');
     $startDate->add(new DateInterval('PT' . $periods_per_day . 'M'));
     $result = getPeriodInterval($start_time, $startDate->getTimestamp());
     // Add in the number of whole days worth of periods in between
     $result += ($interval_days - 1) * $periods_per_day;
     // And add in the number of periods on the last day
-    $result += getPeriodInterval($endDate->modify('12:00')->getTimestamp(), 
$end_time);
+    $result += getPeriodInterval($endDate->getTimestamp(), $end_time);
   }
   
   return (int)$result;
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to