[open-ils-commits] r16846 - trunk/Open-ILS/web/js/dojo/openils (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jul 2 15:41:48 EDT 2010


Author: erickson
Date: 2010-07-02 15:41:43 -0400 (Fri, 02 Jul 2010)
New Revision: 16846

Modified:
   trunk/Open-ILS/web/js/dojo/openils/Util.js
Log:
repaired bug where parsing intervals with months failed becuase dojo.date.add() wants the full word 'months' whereas postgres stores them abbreviated as 'mons'

Modified: trunk/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/Util.js	2010-07-01 19:46:45 UTC (rev 16845)
+++ trunk/Open-ILS/web/js/dojo/openils/Util.js	2010-07-02 19:41:43 UTC (rev 16846)
@@ -222,8 +222,17 @@
         var d = new Date();
         var start = d.getTime();
         var parts = interval.split(' ');
-        for(var i = 0; i < parts.length; i += 2) 
-            d = dojo.date.add(d, parts[i+1].replace(/s?,?$/,''), Number(parts[i]));
+        for(var i = 0; i < parts.length; i += 2)  {
+            var type = parts[i+1].replace(/s?,?$/,'');
+            switch(type) {
+                case 'mon': // postgres
+                    type = 'month'; // dojo
+                    break;
+                // add more as necessary
+            }
+
+            d = dojo.date.add(d, type, Number(parts[i]));
+        }
         return Number((d.getTime() - start) / 1000);
     };
 



More information about the open-ils-commits mailing list