Roo/util/Observable.js
[roojs1] / roojs-core-debug.js
index e655f12..f4d8528 100644 (file)
@@ -1205,12 +1205,35 @@ document.write(dt.format(Date.patterns.ShortDate));
 /**
  Returns the number of milliseconds between this date and date
  @param {Date} date (optional) Defaults to now
- @return {Number} The diff in milliseconds
+ @param {String} interval (optional) Default Date.MILLI, A valid date interval enum value (eg. Date.DAY) 
+ @return {Number} The diff in milliseconds or units of interval
  @member Date getElapsed
  */
-Date.prototype.getElapsed = function(date) {
-       return Math.abs((date || new Date()).getTime()-this.getTime());
+Date.prototype.getElapsed = function(date, interval)
+{
+    date = date ||  new Date();
+    var ret = Math.abs(date.getTime()-this.getTime());
+    switch (interval) {
+       
+        case  Date.SECOND:
+            return Math.floor(ret / (1000));
+        case  Date.MINUTE:
+            return Math.floor(ret / (1000*60));
+        case  Date.HOUR:
+            return Math.floor(ret / (1000*60*60));
+        case  Date.DAY:
+            return Math.floor(ret / (1000*60*60*24));
+        case  Date.MONTH: // this does not give exact number...??
+            return ((date.format("Y") - this.format("Y")) * 12) + (date.format("m") - this.format("m"));
+        case  Date.YEAR: // this does not give exact number...??
+            return (date.format("Y") - this.format("Y"));
+       
+        case  Date.MILLI:
+        default:
+            return ret;
+    }
 };
 // was in date file..
 
 
@@ -7101,6 +7124,8 @@ Roo.query = Roo.DomQuery.select;
  */
 
 Roo.util.Observable = function(cfg){
+    console.log("UTIL OBSERVABLE CONSTRUCTOR");
+    consolg.log("config");
     
     cfg = cfg|| {};
     this.addEvents(cfg.events || {});
@@ -16842,6 +16867,8 @@ Roo.ComponentMgr = function(){
  * and is used as the component id.  Otherwise, it is assumed to be a standard config object and is applied to the component.
  */
 Roo.Component = function(config){
+    console.log("COMPONENT CONSTRUCTOR");
+    console.log(config);
     config = config || {};
     if(config.tagName || config.dom || typeof config == "string"){ // element object
         config = {el: config, id: config.id || config};