[open-ils-commits] r14978 - trunk/Open-ILS/xul/staff_client/chrome/content/util (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Nov 19 13:33:44 EST 2009


Author: phasefx
Date: 2009-11-19 13:33:40 -0500 (Thu, 19 Nov 2009)
New Revision: 14978

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/util/date.js
Log:
Fix util.date regression in offline mode.  We don't have dojo in that environment, and likely won't bundle it.  So back to original parsing for db_date2Date if no dojo, and don't offer the %{localized} and %{iso8601} format options if no dojo.  At least for now.

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/date.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/date.js	2009-11-19 16:25:20 UTC (rev 14977)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/date.js	2009-11-19 18:33:40 UTC (rev 14978)
@@ -46,8 +46,18 @@
 }
 
 util.date.db_date2Date = function (db_date) {
-    dojo.require('dojo.date.stamp');
-    return dojo.date.stamp.fromISOString( db_date.replace( /^(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d-\d\d)(\d\d)$/, '$1:$2') );
+    if (typeof window.dojo != 'undefined') {
+        dojo.require('dojo.date.stamp');
+        return dojo.date.stamp.fromISOString( db_date.replace( /^(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d-\d\d)(\d\d)$/, '$1:$2') );
+    } else {
+        var y  = date.substr(0,4); 
+        var mo = date.substr(5,2); 
+        var d  = date.substr(8,2); 
+        var h  = date.substr(11,2); 
+        var mi = date.substr(14,2); 
+        var s  = date.substr(17,2); 
+        return new Date(y,mo-1,d,h,mi,s); 
+    }
 }
 
 util.date.formatted_date = function (orig_date,format) {
@@ -80,14 +90,15 @@
     var M = _date.getMinutes(); M = M.toString(); if (M.length == 1) M = '0' + M;
     var sec = _date.getSeconds(); sec = sec.toString(); if (sec.length == 1) sec = '0' + sec;
 
-    dojo.require('dojo.date.locale');
-    dojo.require('dojo.date.stamp');
-
     var s = format;
     if (s == '') { s = '%F %H:%M'; }
-    s = s.replace( /%\{localized\}/g, dojo.date.locale.format( _date ) );
-    s = s.replace( /%\{localized_date\}/g, dojo.date.locale.format( _date, { 'selector' : 'date' } ) );
-    s = s.replace( /%\{iso8601\}/g, dojo.date.stamp.toISOString( _date ) );
+    if (typeof window.dojo != 'undefined') {
+        dojo.require('dojo.date.locale');
+        dojo.require('dojo.date.stamp');
+        s = s.replace( /%\{localized\}/g, dojo.date.locale.format( _date ) );
+        s = s.replace( /%\{localized_date\}/g, dojo.date.locale.format( _date, { 'selector' : 'date' } ) );
+        s = s.replace( /%\{iso8601\}/g, dojo.date.stamp.toISOString( _date ) );
+    }
     s = s.replace( /%m/g, mm );
     s = s.replace( /%d/g, dd );
     s = s.replace( /%Y/g, yyyy );



More information about the open-ils-commits mailing list