From c329d7d8e6d6bc53f3f73b784ff403bbe103beb9 Mon Sep 17 00:00:00 2001
From: Yoshinori Okuji <yo@nexedi.com>
Date: Sat, 11 Aug 2007 13:58:34 +0000
Subject: [PATCH] Copy dates rather than patching deltas, because floating
 points are not so reliable for milliseconds. This should be probably applied
 to CopyToTarget as well.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15615 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../TargetSolver/ResourceBackpropagation.py   | 20 +++++++++----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/product/ERP5/TargetSolver/ResourceBackpropagation.py b/product/ERP5/TargetSolver/ResourceBackpropagation.py
index 26999a8071..1713a0b3d2 100755
--- a/product/ERP5/TargetSolver/ResourceBackpropagation.py
+++ b/product/ERP5/TargetSolver/ResourceBackpropagation.py
@@ -51,16 +51,16 @@ class ResourceBackpropagation(CopyToTarget):
     quantity_ratio = 0
     if old_quantity not in (None,0.0): # XXX: What if quantity happens to be an integer ?
       quantity_ratio = new_quantity / old_quantity
-    start_date_delta = 0
-    stop_date_delta = 0
+    start_date = None
+    stop_date = None
     if new_start_date is not None and old_start_date is not None:
-      start_date_delta = new_start_date - old_start_date
+      start_date = new_start_date
     if new_stop_date is not None and old_stop_date is not None:
-      stop_date_delta = new_stop_date - old_stop_date
+      stop_date = new_stop_date
     return {
       'quantity_ratio': quantity_ratio,
-      'start_date_delta': start_date_delta,
-      'stop_date_delta': stop_date_delta,
+      'start_date': start_date,
+      'stop_date': stop_date,
       'resource_list' :
           simulation_movement.getDeliveryValue().getResourceList(),
       'variation_category_list':
@@ -70,7 +70,7 @@ class ResourceBackpropagation(CopyToTarget):
     }
 
   def _generateValueDict(self, simulation_movement, quantity_ratio=1, 
-                         start_date_delta=0, stop_date_delta=0,
+                         start_date=None, stop_date=None,
                          resource_list=[],
                          variation_category_list=[],
                          variation_property_dict={},
@@ -80,12 +80,10 @@ class ResourceBackpropagation(CopyToTarget):
     """
     value_dict = {}
     # Modify quantity, start_date, stop_date
-    start_date = simulation_movement.getStartDate()
     if start_date is not None:
-      value_dict['start_date'] = start_date + start_date_delta
-    stop_date = simulation_movement.getStopDate()
+      value_dict['start_date'] = start_date
     if stop_date is not None:
-      value_dict['stop_date'] = stop_date + stop_date_delta
+      value_dict['stop_date'] = stop_date
     value_dict['quantity'] = simulation_movement.getQuantity() * quantity_ratio
     if resource_list:
       value_dict['resource_list'] = resource_list
-- 
2.30.9