[Erp5-report] r13985 - /erp5/trunk/products/ERP5/Document/CalendarPeriod.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Apr 5 18:11:42 CEST 2007


Author: romain
Date: Thu Apr  5 18:11:41 2007
New Revision: 13985

URL: http://svn.erp5.org?rev=13985&view=rev
Log:
Improve precision in time calculation

Modified:
    erp5/trunk/products/ERP5/Document/CalendarPeriod.py

Modified: erp5/trunk/products/ERP5/Document/CalendarPeriod.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/CalendarPeriod.py?rev=13985&r1=13984&r2=13985&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/CalendarPeriod.py (original)
+++ erp5/trunk/products/ERP5/Document/CalendarPeriod.py Thu Apr  5 18:11:41 2007
@@ -143,9 +143,9 @@
       stop_date = self.getStopDate(start_date)
       periodicity_stop_date = self.getPeriodicityStopDate(
                                           start_date)
-      duration = stop_date - start_date
+      second_duration = int(stop_date) - int(start_date)
       # First date has to respect the periodicity config
-      next_start_date = self.getNextPeriodicalDate(start_date-1)
+      next_start_date = self.getNextPeriodicalDate(addToDate(start_date, day=-1))
       while (next_start_date is not None) and \
         (next_start_date <= periodicity_stop_date):
 
@@ -163,7 +163,8 @@
            (current_exception_date < next_start_date.Date()):
           # SQL method don't like iterator
 #             yield (next_start_date, next_start_date+duration)
-          result.append([next_start_date, next_start_date+duration])
+          result.append([next_start_date, addToDate(next_start_date, 
+                                                    second=second_duration)])
           # Update the next exception date
           if len(exception_date_list) != 0:
             current_exception_date = exception_date_list.pop(0).Date()
@@ -172,7 +173,8 @@
         else:
           # SQL method don't like iterator
 #             yield (next_start_date, next_start_date+duration)
-          result.append([next_start_date, next_start_date+duration])
+          result.append([next_start_date, addToDate(next_start_date,
+                                                    second=second_duration)])
         next_start_date = self.getNextPeriodicalDate(next_start_date)
 
     return result




More information about the Erp5-report mailing list