details:   https://code.openbravo.com/erp/devel/pi/rev/d3337dfe6180
changeset: 22143:d3337dfe6180
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Wed Feb 26 10:05:46 2014 +0100
summary:   Fixes issue 25838: Time fields work properly in timezones with 
negative offsets

There was a problem the todays date was assigned to a datetime:

Original date: 31/12/2013 10:00:00
Todays date: 25/02/2014

The assignment order was year, month day, so the datetime was transformed like 
this:
Year updated: 31/12/2014 10:00:00
Month updated: 31/02/2014 does not exists, so it is converted to 03/03/2014
Day updated: 25/03/2014

This has been fixed by changing the updating order to Day, Month, Year. Before 
the update the date month is set to January to prevent setting a day not 
supported by the current month.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js
 |  9 +++++++--
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
          |  9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r 886a6e59bc62 -r d3337dfe6180 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js
        Tue Feb 25 19:13:47 2014 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/formitem/ob-formitem-time.js
        Wed Feb 26 10:05:46 2014 +0100
@@ -78,9 +78,14 @@
 
   setTodaysDate: function (date) {
     var today = new Date();
+    // Set the month initially to January to prevent error like this
+    // provided date: 15/02/2014
+    // today: 31/03/2014
+    // date.setDate(today.getDate()) would result in Mon Mar 02 2014 18:00:00 
GMT+0100 (CET), because february does not have 31 days 
+    date.setMonth(0);
+    date.setDate(today.getDate());
+    date.setMonth(today.getMonth());
     date.setYear(today.getFullYear());
-    date.setMonth(today.getMonth());
-    date.setDate(today.getDate());
   },
 
   /* The following functions allow proper timeGrid operation */
diff -r 886a6e59bc62 -r d3337dfe6180 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Tue Feb 25 19:13:47 2014 +0000
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Wed Feb 26 10:05:46 2014 +0100
@@ -2197,11 +2197,16 @@
   convertToDate: function (stringValue) {
     var today = new Date(),
         dateValue = isc.Time.parseInput(stringValue);
+    // Set the month initially to January to prevent error like this
+    // provided date: 15/02/2014
+    // today: 31/03/2014
+    // date.setDate(today.getDate()) would result in Mon Mar 02 2014 18:00:00 
GMT+0100 (CET), because february does not have 31 days 
+    dateValue.setMonth(0);
     // Only the time is relevant. In order to be able to convert it from UTC 
to local time
     //   properly the date value should be today's date
+    dateValue.setDate(today.getDate());
+    dateValue.setMonth(today.getMonth());
     dateValue.setYear(today.getFullYear());
-    dateValue.setMonth(today.getMonth());
-    dateValue.setDate(today.getDate());
     return dateValue;
   },
 

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to