From 5617dc9558fb574a70f5bfe8456bae05abb7b280 Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 19 Nov 2009 05:43:47 +0000 Subject: [PATCH] Use Dojo for parsing date strings from the database into javascript date objects, and for turning dates into ISO8601 date strings. Stop using DP_DateExtensions.js. Add a {localized} format for util.date.formatted_date, using Dojo. git-svn-id: svn://svn.open-ils.org/ILS/trunk@14966 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/main/constants.js | 2 -- .../xul/staff_client/chrome/content/util/date.js | 39 +++++----------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 06ba7ce06d..6aae3668d5 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -283,8 +283,6 @@ const urls = { 'org_tree' : '/opac/common/js/' + LOCALE + '/OrgTree.js', 'browser' : '/opac/' + LOCALE + '/skin/default/xml/advanced.xml?nps=1', 'fieldmapper' : '/opac/common/js/fmall.js', - 'isodate_lib_remote' : '/opac/common/js/DP_DateExtensions.js', - 'isodate_lib_local' : 'chrome://open_ils_staff_client/content/OpenILS/util/DP_DateExtensions.js', 'xsl_marc2html' : '/opac/extras/xsl/oilsMARC21slim2HTML.xsl', 'AUDIO_GOOD_SOUND' : '/xul/server/skin/media/audio/bonus.wav', 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 0b5b0efc94..071b754c20 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/date.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/date.js @@ -45,14 +45,9 @@ util.date.timer_elapsed = function (id) { return( ms + 'ms (' + ms/1000 + 's)' ); } -util.date.db_date2Date = function (date) { - 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.db_date2Date = function (db_date) { + dojo.require('dojo.date.stamp'); + return dojo.date.stamp.fromISOString( db_date ); } util.date.formatted_date = function (orig_date,format) { @@ -85,31 +80,13 @@ 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'; } - if (typeof _date.iso8601Format != 'function') { - - try { - var js = JSAN._loadJSFromUrl( urls.isodate_lib_remote ); - eval( js ); - - } catch(E) { - - try { - var js = JSAN._loadJSFromUrl( urls.isodate_lib_local ); - eval( js ); - - } catch(F) { - - alert('Problem loading ISO8601 date extension:' + E + '\n' + F); - - } - } - - } - if (typeof _date.iso8601Format == 'function') { - s = s.replace( /%\{iso8601\}/g, _date.iso8601Format("YMDHMS") ); - } + s = s.replace( /%\{localized\}/g, dojo.date.locale.format( _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 ); -- 2.11.0