Fixes issue 19070: When you enter a date previous to 01-01-0100 the date changed when you save
authorMartin Taal <martin.taal@openbravo.com>
Tue, 13 Dec 2011 17:29:23 +0100
changeset 14860 b35b26fe024d
parent 14859 96ed1683411a
child 14861 8dbb94fbbb00
child 14867 f22a1c536caf
Fixes issue 19070: When you enter a date previous to 01-01-0100 the date changed when you save
Change parsing of xml schema date to use js date function setFullYear
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Tue Dec 13 16:43:00 2011 +0100
+++ b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Tue Dec 13 17:29:23 2011 +0100
@@ -667,6 +667,44 @@
 
 });
 
+isc.addProperties(isc.Date, {
+//http://forums.smartclient.com/showthread.php?p=77883#post77883
+  createLogicalDate: function (year, month, date, suppressConversion) {
+    var d = new Date(); 
+    d.setHours(12);
+    d.setMinutes(0);
+    d.setSeconds(0);
+    d.setMilliseconds(0);
+    if (date !== null) {
+      d.setDate(1);
+    }
+    if (year !== null) {
+      d.setFullYear(year);
+    }
+    if (month !== null) {
+      d.setMonth(month);
+    }
+    if (date !== null) {
+      d.setDate(date);
+    }
+    
+    if (suppressConversion) {
+        // If the 'suppressConversion' flag was passed, we will want to return null to indicate
+        // we were passed an invalid date if the values passed in had to be converted
+        // (For example a month of 13 effecting the year, etc)
+        var isValid = (d.getFullYear() === year &&
+                       d.getMonth() === month &&
+                       d.getDate() === date );
+        if (!isValid) {
+          return null;
+        }
+    }
+    
+    d.logicalDate = true;
+    return d;
+  }
+});
+
 isc.DateItem.changeDefaults('textFieldDefaults', {
   isDisabled: function() {
     var disabled = this.Super('isDisabled', arguments);