From: phasefx Date: Thu, 19 Nov 2009 18:33:40 +0000 (+0000) Subject: Fix util.date regression in offline mode. We don't have dojo in that environment... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=97aee2e730dc88f716d16db3b9ed63eee46cd8e8;p=evergreen%2Ftadl.git 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@14978 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/chrome/content/util/date.js b/Open-ILS/xul/staff_client/chrome/content/util/date.js index 2f67d9dd69..9147e1ab02 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/date.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/date.js @@ -46,8 +46,18 @@ util.date.timer_elapsed = function (id) { } 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 @@ util.date.formatted_date = function (orig_date,format) { 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 );