[open-ils-commits] r17082 - trunk/Open-ILS/web/js/dojo/openils (senator)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Aug 4 17:22:46 EDT 2010
Author: senator
Date: 2010-08-04 17:22:40 -0400 (Wed, 04 Aug 2010)
New Revision: 17082
Modified:
trunk/Open-ILS/web/js/dojo/openils/Util.js
Log:
Provide a handy method for dojo-based interfaces to correctly show timestamps
from fieldmapper object fields.
Modified: trunk/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/Util.js 2010-08-04 20:43:44 UTC (rev 17081)
+++ trunk/Open-ILS/web/js/dojo/openils/Util.js 2010-08-04 21:22:40 UTC (rev 17082)
@@ -22,11 +22,33 @@
if(!dojo._hasResource["openils.Util"]) {
dojo._hasResource["openils.Util"] = true;
dojo.provide("openils.Util");
+ dojo.require("dojo.date.locale");
+ dojo.require("dojo.date.stamp");
dojo.require('openils.Event');
dojo.declare('openils.Util', null, {});
/**
+ * Returns a locale-appropriate representation of a timestamp when the
+ * timestamp (first argument) is actually a string as provided by
+ * fieldmapper objects.
+ * The second argument is an optional argument that will be provided
+ * as the second argument to dojo.date.locale.format()
+ */
+ openils.Util.timeStamp = function(s, opts) {
+ if (typeof(opts) == "undefined") opts = {};
+
+ return dojo.date.locale.format(
+ dojo.date.stamp.fromISOString(
+ s.replace(
+ /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[\+-]\d{2})(\d{2})$/,
+ "$1:$2"
+ )
+ ), opts
+ );
+ };
+
+ /**
* Wrapper for dojo.addOnLoad that verifies a valid login session is active
* before adding the function to the onload set
*/
More information about the open-ils-commits
mailing list