From 6e9ed09a1abc1b0a9adf9d20b24f5588dce47246 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 5 May 2006 02:43:48 +0000 Subject: [PATCH] added date code directly to utils.js git-svn-id: svn://svn.open-ils.org/ILS/trunk@4093 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/common/js/utils.js | 26 +++++++++++++++++++ .../xul/staff_client/server/patron/ue.xhtml | 2 ++ 2 files changed, 28 insertions(+) diff --git a/Open-ILS/web/opac/common/js/utils.js b/Open-ILS/web/opac/common/js/utils.js index 0214f8e0bf..260f822b79 100644 --- a/Open-ILS/web/opac/common/js/utils.js +++ b/Open-ILS/web/opac/common/js/utils.js @@ -459,3 +459,29 @@ function iterate( arr, callback ) { } + + +/* taken directly from the JSAN util.date library */ +if (typeof util == 'undefined') var util = {}; +util.date = {}; +util.date.interval_to_seconds = function ( $interval ) { + + $interval = $interval.replace( /and/, ',' ); + $interval = $interval.replace( /,/, ' ' ); + + var $amount = 0; + var results = $interval.match( /\s*\+?\s*(\d+)\s*(\w{1})\w*\s*/g); + for (var i in results) { + var result = results[i].match( /\s*\+?\s*(\d+)\s*(\w{1})\w*\s*/ ); + if (result[2] == 's') $amount += result[1] ; + if (result[2] == 'm') $amount += 60 * result[1] ; + if (result[2] == 'h') $amount += 60 * 60 * result[1] ; + if (result[2] == 'd') $amount += 60 * 60 * 24 * result[1] ; + if (result[2] == 'w') $amount += 60 * 60 * 24 * 7 * result[1] ; + if (result[2] == 'M') $amount += ((60 * 60 * 24 * 365)/12) * result[1] ; + if (result[2] == 'y') $amount += 60 * 60 * 24 * 365 * result[1] ; + } + return $amount; +} + + diff --git a/Open-ILS/xul/staff_client/server/patron/ue.xhtml b/Open-ILS/xul/staff_client/server/patron/ue.xhtml index 4c93ae6f39..ca4f7fd639 100644 --- a/Open-ILS/xul/staff_client/server/patron/ue.xhtml +++ b/Open-ILS/xul/staff_client/server/patron/ue.xhtml @@ -26,7 +26,9 @@ + -- 2.43.2