From: phasefx Date: Mon, 26 Apr 2010 21:42:45 +0000 (+0000) Subject: replace lingering date substring kludges with util.date/dojo.locale. In some places... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=aa6943c2e6f9364f79a900c518669fe943a64448;p=evergreen%2Fpines.git replace lingering date substring kludges with util.date/dojo.locale. In some places (like due dates) I'm letting the whole timestamp show where before we were showing just the date git-svn-id: svn://svn.open-ils.org/ILS/trunk@16317 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/xul/staff_client/server/admin/hold_pull_list_classic.js b/Open-ILS/xul/staff_client/server/admin/hold_pull_list_classic.js index 5d11d9906e..e3801dbe3d 100644 --- a/Open-ILS/xul/staff_client/server/admin/hold_pull_list_classic.js +++ b/Open-ILS/xul/staff_client/server/admin/hold_pull_list_classic.js @@ -17,6 +17,7 @@ function pullListInit() { JSAN.errorLevel = "die"; // none, warn, or die JSAN.addRepository('/xul/server/'); JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve(); + JSAN.use('util.date'); fetchUser(); $('pl_user').appendChild(text(USER.usrname())); @@ -102,7 +103,7 @@ function pullListDrawCopy( tbody, row, hold, idx, copy ) { $n(row, 'copy_number').appendChild(text(copy.copy_number())); try { if (copy.age_protect()) { - $n(row, 'age_protect').appendChild(text( (copy.age_protect() == null ? '' : ( typeof copy.age_protect() == 'object' ? copy.age_protect().name() : g.data.hash.crahp[ copy.age_protect() ].name() )) + ' (' + copy.create_date().substr(0,10) + ')' )); + $n(row, 'age_protect').appendChild(text( (copy.age_protect() == null ? '' : ( typeof copy.age_protect() == 'object' ? copy.age_protect().name() : g.data.hash.crahp[ copy.age_protect() ].name() )) + ' (' + util.date.formatted_date( copy.create_date(), '%{localized_date}' ) + ')' )); unHideMe($n(row, 'age_protect_span')); } } catch(E) { alert(E); } diff --git a/Open-ILS/xul/staff_client/server/cat/copy_notes.xul b/Open-ILS/xul/staff_client/server/cat/copy_notes.xul index b27cb81f3e..f04987af46 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_notes.xul +++ b/Open-ILS/xul/staff_client/server/cat/copy_notes.xul @@ -97,7 +97,7 @@ /* template */ var node = $('note_template').cloneNode(true); np.appendChild(node); node.hidden = false; - apply(node,'create_date',g.notes[i].create_date().toString().substr(0,10)); + apply(node,'create_date', util.date.formatted_date( g.notes[i].create_date(), '%{localized}' )); util.widgets.apply(node,'name','create_date', function(n) { n.setAttribute( @@ -125,7 +125,7 @@ 'command', function(id){ return function() { var r = g.error.yns_alert( - $('catStrings').getFormattedString('staff.cat.copy_notes.delete_note.prompt.msg', [g.notes[id].title(), g.notes[id].create_date().toString().substr(0,10)]), + $('catStrings').getFormattedString('staff.cat.copy_notes.delete_note.prompt.msg', [g.notes[id].title(), util.date.formatted_date( g.notes[id].create_date(), '%{localized}')]), $('catStrings').getString('staff.cat.copy_notes.delete_note.prompt.title'), $('catStrings').getString('staff.cat.copy_notes.delete_note.prompt.yes'), $('catStrings').getString('staff.cat.copy_notes.delete_note.prompt.no'), @@ -181,7 +181,7 @@ note.title( fancy_prompt_data.title ); if (fancy_prompt_data.initials) { fancy_prompt_data.note = fancy_prompt_data.note - + $("commonStrings").getFormattedString('staff.initials.format',[fancy_prompt_data.initials,util.date.formatted_date(new Date(),'%F'), ses('ws_ou_shortname')]); + + $("commonStrings").getFormattedString('staff.initials.format',[fancy_prompt_data.initials,util.date.formatted_date(new Date(),'%{localized_date}'), ses('ws_ou_shortname')]); } note.value( fancy_prompt_data.note ); note.pub( get_bool( fancy_prompt_data.pub ) ? get_db_true() : get_db_false() ); diff --git a/Open-ILS/xul/staff_client/server/cat/util.js b/Open-ILS/xul/staff_client/server/cat/util.js index abee34518b..8e9a187367 100644 --- a/Open-ILS/xul/staff_client/server/cat/util.js +++ b/Open-ILS/xul/staff_client/server/cat/util.js @@ -321,7 +321,7 @@ cat.util.mark_item_damaged = function(copy_ids) { var error; try { JSAN.use('util.error'); error = new util.error(); - JSAN.use('util.functional'); + JSAN.use('util.functional'); JSAN.use('util.date'); JSAN.use('util.network'); var network = new util.network(); var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ copy_ids ]); if (typeof copies.ilsevent != 'undefined') throw(copies); @@ -357,7 +357,7 @@ cat.util.mark_item_damaged = function(copy_ids) { my_circ = my_circ[0]; if (typeof my_circ != 'undefined') { if (! my_circ.checkin_time() ) { - var due_date = my_circ.due_date() ? my_circ.due_date().substr(0,10) : null; + var due_date = my_circ.due_date() ? util.date.formatted_date( my_circ.due_date(), '%F' ) : null; var auto_checkin = String( data.hash.aous['circ.auto_checkin_on_mark_damage'] ) == 'true'; /* short-circuit this behavior. We don't want to mark an item damaged and still have it circulating. At least for now. Wait until someone asks for it. */ auto_checkin = true; @@ -367,7 +367,7 @@ cat.util.mark_item_damaged = function(copy_ids) { var msg = $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.item_circulating_to_patron', [ copies[i].barcode(), patron_name, - my_circ.due_date().substr(0,10)]); // FIXME: need to replace date handling + util.date.formatted_date( my_circ.due_date(), '%{localized}' )]); JSAN.use('util.date'); var today = util.date.formatted_date(new Date(),'%F'); var r2 = auto_checkin ? 1 : error.yns_alert( msg, @@ -404,7 +404,7 @@ cat.util.mark_item_damaged = function(copy_ids) { $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.charge_patron_prompt.message', [ copies[i].barcode(), patron_name, - circ_obj.checkin_time().substr(0,10), // FIXME: need to replace with something better + util.date.formatted_date( circ_obj.checkin_time(), '%{localized}' ), util.money.sanitize(robj.payload.charge) ]), $("catStrings").getString('staff.cat.util.mark_item_damaged.charge_patron_prompt.title'), $("catStrings").getString('staff.cat.util.mark_item_damaged.charge_patron_prompt.ok_label'), diff --git a/Open-ILS/xul/staff_client/server/circ/checkout.js b/Open-ILS/xul/staff_client/server/circ/checkout.js index 9e1a46cf29..366017a818 100644 --- a/Open-ILS/xul/staff_client/server/circ/checkout.js +++ b/Open-ILS/xul/staff_client/server/circ/checkout.js @@ -568,6 +568,7 @@ circ.checkout.prototype = { 'checkout' : function(params) { var obj = this; + JSAN.use('util.date'); if (document.getElementById('checkout_duedate_checkbox').checked) { if (! obj.check_date(obj.controller.view.checkout_duedate_datepicker)) return; var tp = document.getElementById('checkout_duedate_timepicker'); @@ -578,7 +579,6 @@ circ.checkout.prototype = { tp_date.setMonth( dp_date.getMonth() ); tp_date.setDate( dp_date.getDate() ); - JSAN.use('util.date'); params.due_date = util.date.formatted_date(tp_date,'%{iso8601}'); } @@ -853,11 +853,11 @@ circ.checkout.prototype = { if (! stop_checkout ) { - var due_date = my_circ.due_date() ? my_circ.due_date().substr(0,10) : null; + var due_date = my_circ.due_date() ? util.date.formatted_date( my_circ.due_date(), '%F' ) : null; JSAN.use('util.date'); var today = util.date.formatted_date(new Date(),'%F'); if (due_date) { if (today > due_date) { - msg += (document.getElementById('circStrings').getFormattedString('staff.circ.checkout.item_due', [due_date]) + '\n'); + msg += (document.getElementById('circStrings').getFormattedString('staff.circ.checkout.item_due', [ util.date.formatted_date( my_circ.due_date(), '%{localized}' ) ]) + '\n'); } } diff --git a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul index e82f5c8353..22bc2ccb23 100644 --- a/Open-ILS/xul/staff_client/server/circ/circ_brief.xul +++ b/Open-ILS/xul/staff_client/server/circ/circ_brief.xul @@ -55,15 +55,15 @@ try { var r_circ = req.getResultObject(); $('circ_lib').value = r_circ.circ_lib() ? g.data.hash.aou[ r_circ.circ_lib() ].shortname() : ''; - $('xact_start').value = r_circ.xact_start() ? r_circ.xact_start().toString().substr(0,16).replace(/T/,' ') : ''; - $('due_date').value = r_circ.due_date() ? r_circ.due_date().toString().substr(0,10) : ''; + $('xact_start').value = r_circ.xact_start() ? util.date.formatted_date( r_circ.xact_start(), '%{localized}' ) : ''; + $('due_date').value = r_circ.due_date() ? util.date.formatted_date( r_circ.due_date(), '%{localized}' ) : ''; $('circ_lib').setAttribute('tooltiptext', document.getElementById('circStrings').getFormattedString('staff.circ.circ_brief.staff_out_id', [r_circ.circ_staff()]) ); $('checkin_lib').value = r_circ.checkin_lib() ? g.data.hash.aou[ r_circ.checkin_lib() ].shortname() : ''; - $('checkin_time').value = r_circ.checkin_time() ? r_circ.checkin_time().toString().substr(0,16).replace(/T/,' ') : ''; + $('checkin_time').value = r_circ.checkin_time() ? util.date.formatted_date( r_circ.checkin_time(), '%{localized}' ) : ''; $('checkin_lib').setAttribute('tooltiptext', document.getElementById('circStrings').getFormattedString('staff.circ.circ_brief.staff_in_id', [r_circ.checkin_staff()]) ); $('id').value = r_circ.id() ? r_circ.id() : ''; $('stop_fines').value = r_circ.stop_fines() ? r_circ.stop_fines() : ''; - $('stop_fines_time').value = r_circ.stop_fines_time() ? r_circ.stop_fines_time().toString().substr(0,16).replace(/T/,' ') : ''; + $('stop_fines_time').value = r_circ.stop_fines_time() ? util.date.formatted_date( r_circ.stop_fines_time(), '%{localized}' ) : ''; var r = ''; if (get_bool( r_circ.desk_renewal() ) ) r += 'DESK '; if (get_bool(r_circ.opac_renewal() ) ) r += 'OPAC '; diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.js b/Open-ILS/xul/staff_client/server/patron/bill_details.js index c182ae5482..05c2c6e295 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.js @@ -21,8 +21,8 @@ function retrieve_mbts() { g.mbts = req.getResultObject(); $('mbts_id').value = g.mbts.id(); $('mbts_xact_type').value = g.mbts.xact_type(); - $('mbts_xact_start').value = g.mbts.xact_start().toString().substr(0,19); - $('mbts_xact_finish').value = g.mbts.xact_finish() ? g.mbts.xact_finish().toString().substr(0,19) : ''; + $('mbts_xact_start').value = util.date.formatted_date( g.mbts.xact_start(), '%{localized}' ); + $('mbts_xact_finish').value = g.mbts.xact_finish() ? util.date.formatted_date( g.mbts.xact_finish(), '%{localized}' ) : ''; $('mbts_total_owed').value = g.mbts.total_owed() ? util.money.sanitize( g.mbts.total_owed() ) : ''; $('mbts_total_paid').value = g.mbts.total_paid() ? util.money.sanitize( g.mbts.total_paid() ) : ''; $('mbts_balance_owed').value = g.mbts.balance_owed() ? util.money.sanitize( g.mbts.balance_owed() ) : ''; @@ -76,9 +76,9 @@ function retrieve_circ() { $('checked_out_label').hidden = false; $('due_label').hidden = false; $('checked_in_label').hidden = false; - $('checked_out').value = r_circ.xact_start() ? r_circ.xact_start().toString().substr(0,10) : ''; - $('checked_in').value = r_circ.checkin_time() ? r_circ.checkin_time().toString().substr(0,10) : ''; - $('due').value = r_circ.due_date() ? r_circ.due_date().toString().substr(0,10) : ''; + $('checked_out').value = r_circ.xact_start() ? util.date.formatted_date( r_circ.xact_start(), '%{localized}' ) : ''; + $('checked_in').value = r_circ.checkin_time() ? util.date.formatted_date( r_circ.checkin_time(), '%{localized}' ) : ''; + $('due').value = r_circ.due_date() ? util.date.formatted_date( r_circ.due_date(), '%{localized}' ) : ''; $('billing_location').value = g.data.hash.aou[ r_circ.circ_lib() ].shortname() + ' : ' + g.data.hash.aou[ r_circ.circ_lib() ].name(); var r = ''; if (get_bool( r_circ.desk_renewal() ) ) r += 'DESK '; diff --git a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js index f9461ab9fd..ae4035ada1 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_wizard.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_wizard.js @@ -7,8 +7,8 @@ function retrieve_mbts() { g.mbts = req.getResultObject(); $('mbts_id').value = g.mbts.id(); $('mbts_xact_type').value = g.mbts.xact_type(); - $('mbts_xact_start').value = g.mbts.xact_start().toString().substr(0,19); - $('mbts_xact_finish').value = g.mbts.xact_finish() ? g.mbts.xact_finish().toString().substr(0,19) : ''; + $('mbts_xact_start').value = util.date.formatted_date( g.mbts.xact_start(), '%{localized}' ); + $('mbts_xact_finish').value = g.mbts.xact_finish() ? util.date.formatted_date( g.mbts.xact_finish(), '%{localized}' ) : ''; $('mbts_total_owed').value = g.mbts.total_owed() ? util.money.sanitize( g.mbts.total_owed() ) : ''; $('mbts_total_paid').value = g.mbts.total_paid() ? util.money.sanitize( g.mbts.total_paid() ) : ''; $('mbts_balance_owed').value = g.mbts.balance_owed() ? util.money.sanitize( g.mbts.balance_owed() ) : ''; @@ -29,9 +29,9 @@ function retrieve_circ() { $('checked_out_label').hidden = false; $('due_label').hidden = false; $('checked_in_label').hidden = false; - $('checked_out').value = r_circ.xact_start() ? r_circ.xact_start().toString().substr(0,10) : ''; - $('checked_in').value = r_circ.checkin_time() ? r_circ.checkin_time().toString().substr(0,10) : ''; - $('due').value = r_circ.due_date() ? r_circ.due_date().toString().substr(0,10) : ''; + $('checked_out').value = r_circ.xact_start() ? util.date.formatted_date( r_circ.xact_start(), '%{localized}' ) : ''; + $('checked_in').value = r_circ.checkin_time() ? util.date.formatted_date( r_circ.checkin_time(), '%{localized}' ) : ''; + $('due').value = r_circ.due_date() ? util.date.formatted_date( r_circ.due_date(), '%{localized}' ) : ''; g.network.simple_request( 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.authoritative', diff --git a/Open-ILS/xul/staff_client/server/patron/bills.js b/Open-ILS/xul/staff_client/server/patron/bills.js index 998dd41760..4a7cf0537b 100644 --- a/Open-ILS/xul/staff_client/server/patron/bills.js +++ b/Open-ILS/xul/staff_client/server/patron/bills.js @@ -8,6 +8,7 @@ patron.bills = function (params) { var obj = this; try { JSAN.use('util.error'); obj.error = new util.error(); } catch(E) { alert(E); } try { JSAN.use('util.network'); obj.network = new util.network(); } catch(E) { alert(E); } + JSAN.use('util.date'); try { obj.OpenILS = {}; JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'}); obj.data = obj.OpenILS.data; @@ -744,7 +745,7 @@ patron.bills.prototype = { label_r1_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_xact_start_label')); var label_r1_2 = document.createElement('label'); row1.appendChild( label_r1_2 ); - label_r1_2.setAttribute('value',mobts.xact_start().toString().substr(0,10)); + label_r1_2.setAttribute('value',util.date.formatted_date(mobts.xact_start(),'%{localized}')); var row2 = document.createElement('row'); rows.appendChild( row2 ); var label_r2_1 = document.createElement('label'); @@ -752,7 +753,7 @@ patron.bills.prototype = { label_r2_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_xact_finish_label')); var label_r2_2 = document.createElement('label'); row2.appendChild( label_r2_2 ); - try { label_r2_2.setAttribute('value',mobts.xact_finish().toString().substr(0,10)); + try { label_r2_2.setAttribute('value',util.date.formatted_date(mobts.xact_finish(),'%{localized}')); } catch(E) {} return grid; diff --git a/Open-ILS/xul/staff_client/server/patron/hold_details.js b/Open-ILS/xul/staff_client/server/patron/hold_details.js index 14eb6b4059..083173674c 100644 --- a/Open-ILS/xul/staff_client/server/patron/hold_details.js +++ b/Open-ILS/xul/staff_client/server/patron/hold_details.js @@ -174,7 +174,7 @@ function render_notifications() { ); apply(node,'method',g.notifications[i].method() ? g.notifications[i].method() : ''); apply(node,'note',g.notifications[i].note() ? g.notifications[i].note() : ''); - apply(node,'notify_time',g.notifications[i].notify_time() ? g.notifications[i].notify_time().toString().substr(0,10) : ''); + apply(node,'notify_time',g.notifications[i].notify_time() ? util.date.formatted_date( g.notifications[i].notify_time(), '%{localized}' ) : ''); } } @@ -197,7 +197,6 @@ function render_notes() { ); apply(node,'title',g.notes[i].title() ? g.notes[i].title() : ''); apply(node,'note',g.notes[i].body() ? g.notes[i].body() : ''); - //apply(node,'create_date',g.notes[i].create_date() ? g.notes[i].create_date().toString().substr(0,10) : ''); // FIXME -- need to rework date display more intelligently apply(node,'pub',get_bool( g.notes[i].pub() ) ? $("patronStrings").getString('staff.patron.hold_notes.public') : $("patronStrings").getString('staff.patron.hold_notes.private') ) apply(node,'slip',get_bool( g.notes[i].slip() ) ? $("patronStrings").getString('staff.patron.hold_notes.print_on_slip') : $("patronStrings").getString('staff.patron.hold_notes.no_print_on_slip') ) apply(node,'staff',get_bool( g.notes[i].staff() ) ? $("patronStrings").getString('staff.patron.hold_notes.by_staff') : $("patronStrings").getString('staff.patron.hold_notes.by_patron') ) diff --git a/Open-ILS/xul/staff_client/server/patron/info_notes.xul b/Open-ILS/xul/staff_client/server/patron/info_notes.xul index 589e869175..f0ef3e859a 100644 --- a/Open-ILS/xul/staff_client/server/patron/info_notes.xul +++ b/Open-ILS/xul/staff_client/server/patron/info_notes.xul @@ -103,7 +103,7 @@ /* template */ var node = $('note_template').cloneNode(true); np.appendChild(node); node.hidden = false; - apply(node,'create_date',g.notes[i].create_date().toString().substr(0,10)); + apply(node,'create_date',util.date.formatted_date(g.notes[i].create_date(),'%{localized}')); util.widgets.apply(node,'name','create_date', function(n){n.setAttribute("tooltiptext", $("patronStrings").getFormattedString('staff.patron.info_notes.render_notes.tooltiptext', [g.notes[i].id(), g.notes[i].creator()]));} ); @@ -130,7 +130,7 @@ function(id){ return function() { var r = g.error.yns_alert( - $("patronStrings").getFormattedString('staff.patron.info_notes.render_notes.delete_note_message',[g.notes[id].title(), g.notes[id].create_date().toString().substr(0,10)]), + $("patronStrings").getFormattedString('staff.patron.info_notes.render_notes.delete_note_message',[g.notes[id].title(), util.date.formatted_date(g.notes[id].create_date(),'%{localized}')]), $("patronStrings").getString('staff.patron.info_notes.render_notes.delete_note_title'), $("commonStrings").getString('common.yes'), $("commonStrings").getString('common.no'), @@ -169,7 +169,7 @@ patron.util.format_name( patron_obj ) + ' : ' + patron_obj.card().barcode() + '

' + '

"' + g.notes[id].title() + '"' - + $("patronStrings").getFormattedString('staff.patron.info_notes.render_notes.created_on', [g.notes[id].create_date().toString().substr(0,10), staff_obj[0], g.data.hash.aou[ staff_obj[3] ].shortname()]) + + $("patronStrings").getFormattedString('staff.patron.info_notes.render_notes.created_on', [util.date.formatted_date(g.notes[id].create_date(),'%{localized}'), staff_obj[0], g.data.hash.aou[ staff_obj[3] ].shortname()]) + '

' + g.notes[id].value() + '


' diff --git a/Open-ILS/xul/staff_client/server/patron/summary.js b/Open-ILS/xul/staff_client/server/patron/summary.js index e72de48cdc..df6a166a2b 100644 --- a/Open-ILS/xul/staff_client/server/patron/summary.js +++ b/Open-ILS/xul/staff_client/server/patron/summary.js @@ -9,7 +9,7 @@ patron.summary = function (params) { JSAN.use('util.error'); this.error = new util.error(); JSAN.use('util.window'); this.window = new util.window(); JSAN.use('util.network'); this.network = new util.network(); - JSAN.use('util.widgets'); + JSAN.use('util.widgets'); JSAN.use('util.date'); this.w = window; } @@ -511,7 +511,7 @@ patron.summary.prototype = { util.widgets.set_text(e, patronStrings.getString('staff.patron.summary.expires_on') + ' ' + ( obj.patron.expire_date() ? - obj.patron.expire_date().substr(0,10) : + util.date.formatted_date( obj.patron.expire_date(), '%{localized_date}' ) : patronStrings.getString('staff.patron.field.unset') ) ); @@ -536,7 +536,7 @@ patron.summary.prototype = { if ( obscure_dob && hide_value == 'true' ) { e.setAttribute( 'hidden_value', obj.patron.dob() ? - obj.patron.dob().substr(0,10) : + util.date.formatted_date( obj.patron.dob(), '%{localized_date}' ) : patronStrings.getString('staff.patron.field.unset') ); util.widgets.set_text(e, @@ -545,7 +545,7 @@ patron.summary.prototype = { } else { util.widgets.set_text(e, obj.patron.dob() ? - obj.patron.dob().substr(0,10) : + util.date.formatted_date( obj.patron.dob(), '%{localized_date}' ) : patronStrings.getString('staff.patron.field.unset') ); e.setAttribute( 'hidden_value',