[open-ils-commits] r12213 - trunk/Open-ILS/web/js/dojo/openils (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Feb 17 23:48:36 EST 2009
Author: erickson
Date: 2009-02-17 23:48:34 -0500 (Tue, 17 Feb 2009)
New Revision: 12213
Modified:
trunk/Open-ILS/web/js/dojo/openils/Util.js
Log:
dojo-based interval2seconds
Modified: trunk/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/Util.js 2009-02-18 03:22:34 UTC (rev 12212)
+++ trunk/Open-ILS/web/js/dojo/openils/Util.js 2009-02-18 04:48:34 UTC (rev 12213)
@@ -204,4 +204,18 @@
}
return map;
};
+
+ /**
+ * Assume a space-separated interval string, with optional comma
+ * E.g. "1 year, 2 days" "3 days 6 hours"
+ */
+ openils.Util.intervalToSeconds = function(interval) {
+ 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]));
+ return Number((d.getTime() - start) / 1000);
+ };
}
+
More information about the open-ils-commits
mailing list