define(["dojo/has", "dojo/number", "dojo/date/locale"], function (has, number, locale) { return { // source for supports_local_storage function: // http://diveintohtml5.org/detect.html supports_local_storage: function() { try { return 'localStorage' in window && window['localStorage'] !== null; } catch (e) { return false; } }, toReportOutage: function(reportOutagePageUrl) { var nw = window.open(reportOutagePageUrl, "reportOutage"); nw.focus(); }, toHelp:function(url) { var nw = window.open(url); nw.focus(); }, checkSupportBrowser:function() { var ieVer = has("ie"); if ((typeof ieVer) !== 'undefined') { console.log("ie ver: " + ieVer); if (ieVer < 9) { window.location = "supportBrowers.html"; } } }, formatDate:function(value, isUTC) { // if (value !== undefined) { // var inputDate = new Date(value); // if(!isNaN(inputDate.getTime())) { // var offsetDate = new Date(inputDate.setHours(inputDate.getHours() + inputDate.getTimezoneOffset() / 60)); // var newDt = locale.format(offsetDate, { // selector: "date", // datePattern: "M/dd/yy h:mm a" // }); // return newDt; // } else { // return value; // } // } else { // return ""; // } var bannerUpdateTime = value, currentdate; if (bannerUpdateTime === undefined) { return ""; } else { bannerUpdateTime = bannerUpdateTime.replace(/-/g, '/'); // In case the format is yyyy-mm-dd hh:mm:ss if(isUTC) { bannerUpdateTime += " UTC"; } currentdate = new Date(bannerUpdateTime); } if (!isNaN(currentdate.getTime())) { var hours = currentdate.getHours(); var minutes = currentdate.getMinutes(); var ampm = hours >= 12 ? "pm" : "am"; hours = hours % 12; hours = hours ? hours : 12; // hour '0' should be '12' minutes = minutes < 10 ? "0" + minutes : minutes; var time = hours + ':' + minutes + ' ' + ampm; var date = (currentdate.getMonth() + 1) + "/" + currentdate.getDate() + "/" + currentdate.getFullYear(); return {"date": date, "time": time}; } else { return value; } }, formatNumber:function(value) { if (value !== undefined) { var newNum = number.format(value, { locale: "en-us" }); return newNum; } else { return ""; } }, formatNameList: function(value) { var formattedNamesString = ""; if (value !== undefined && typeof value === "string" ) { var namesArray = value.match(/([^;]+)/g); for(var i=0;i"; continue; } formattedNamesString += "" + namesArray[i] + ",
"; } } return formattedNamesString; } } });