[icinga-checkins] icinga.org: icinga-web/mhein/default: * Allowed Tackle/AppKitUtil. Date to parse Dates with pgsql timezone offset appended

git at icinga.org git at icinga.org
Wed Nov 23 14:57:28 CET 2011


Module: icinga-web
Branch: mhein/default
Commit: 61164f446952945fda61f0f154ef5f1ce79a7c01
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=61164f446952945fda61f0f154ef5f1ce79a7c01

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Tue Nov 22 12:04:57 2011 +0100

* Allowed Tackle/AppKitUtil.Date to parse Dates with pgsql timezone offset appended

---

 app/modules/AppKit/lib/js/AppKitUtil.js            |    4 +++-
 .../Cronks/lib/js/Cronks/Tackle/ObjectGrid.js      |    9 +++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/app/modules/AppKit/lib/js/AppKitUtil.js b/app/modules/AppKit/lib/js/AppKitUtil.js
index 22a8645..1949955 100755
--- a/app/modules/AppKit/lib/js/AppKitUtil.js
+++ b/app/modules/AppKit/lib/js/AppKitUtil.js
@@ -215,7 +215,9 @@ AppKit.util.Date = (function() {
        return {
            getElapsedString: function(value) {
                 var now = new Date();
-                var valueDate = Date.parseDate(value,'Y-m-d H:i:s');
+                var valueDate = Date.parseDate(value,'Y-m-d H:i:s')
+                    || Date.parseDate(value,'Y-m-d H:i:sP')
+                    || Date.parseDate(value+":00",'Y-m-d H:i:sP');
                 var elapsed = parseInt(now.getElapsed(valueDate)/1000,10);
 
                 var dd = parseInt(elapsed/time.day,10);
diff --git a/app/modules/Cronks/lib/js/Cronks/Tackle/ObjectGrid.js b/app/modules/Cronks/lib/js/Cronks/Tackle/ObjectGrid.js
index b7348fe..6318776 100644
--- a/app/modules/Cronks/lib/js/Cronks/Tackle/ObjectGrid.js
+++ b/app/modules/Cronks/lib/js/Cronks/Tackle/ObjectGrid.js
@@ -281,8 +281,13 @@ Icinga.Cronks.Tackle.ObjectGrid = Ext.extend(Ext.grid.GridPanel, {
                 renderer: function(value,meta,record) {
                    var str = AppKit.util.Date.getElapsedString(value);
                    var now = new Date();
-                   var lastCheckDate = Date.parseDate(value,'Y-m-d H:i:s');
-                   var nextCheckDate = Date.parseDate(record.get('HOST_NEXT_CHECK'),'Y-m-d H:i:s');
+                   // Postgresql doesn't return timestamps in format that extjs can read without problems
+                   var lastCheckDate = Date.parseDate(value,'Y-m-d H:i:s') 
+                       || Date.parseDate(value,'Y-m-d H:i:sP')
+                       || Date.parseDate(value+":00",'Y-m-d H:i:sP');
+                   var nextCheckDate = Date.parseDate(record.get('HOST_NEXT_CHECK'),'Y-m-d H:i:s')
+                       || Date.parseDate(record.get('HOST_NEXT_CHECK'),'Y-m-d H:i:sP')
+                       || Date.parseDate(record.get('HOST_NEXT_CHECK')+":00",'Y-m-d H:i:sP');
 
                    var elapsed = parseInt(now.getElapsed(lastCheckDate)/1000,10);
                    





More information about the icinga-checkins mailing list