From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Fri, 2 Jul 2010 19:41:43 +0000 (+0000)
Subject: repaired bug where parsing intervals with months failed becuase dojo.date.add() wants... 
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=180ffeed3d81ed205b21de541fa64b0d4e9576a5;p=contrib%2FConifer.git

repaired bug where parsing intervals with months failed becuase dojo.date.add() wants the full word 'months' whereas postgres stores them abbreviated as 'mons'

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16846 dcc99617-32d9-48b4-a31d-7c20da2025e4
---

diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js
index f535e227b4..fd3a2d1376 100644
--- a/Open-ILS/web/js/dojo/openils/Util.js
+++ b/Open-ILS/web/js/dojo/openils/Util.js
@@ -222,8 +222,17 @@ if(!dojo._hasResource["openils.Util"]) {
         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);
     };