var TimeManager = { timeStampDiff: '', init: function () { Ext.Ajax.request({ url : 'ajax2/Gemini?action=demand.web.ajax.GetCurrentTimeStampAction', params : {}, success: function (response, options) { var serverTimeStamp = response.responseText; var localDate = new Date(); var localTimeStamp = localDate.getTime(); timeStampDiff = serverTimeStamp - localTimeStamp; } }); }, getAdjustedTime: function () { var localDate = new Date(); var nd = new Date (localDate.getTime() + timeStampDiff + localDate.getTimezoneOffset()); var month = nd.getMonth() + 1; if (month < 10) month = "0" + month; var day = nd.getDate(); if (day < 10) day = "0" + day; var hours = nd.getHours(); if (hours < 10) hours = "0" + hours; var minutes = nd.getMinutes(); if (minutes < 10) minutes = "0" + minutes; var seconds = nd.getSeconds(); if (seconds < 10) seconds = "0" + seconds; return nd.getFullYear()+'-'+month+'-'+day+' '+hours+':'+minutes+':'+seconds }, convertToLocaleDate: function (stdDate) { // stdDateTime must be of the format "yyyy-MM-dd" if (!stdDate) return ""; // set date to appropriate locale #set ($localeFormat = $CommonFunctions.localeDateFormat()) var localeFormat = "$localeFormat"; // split the year, month, day var dateTokens = stdDate.split("-"); var month = dateTokens[1]; var day = dateTokens[2]; return localeFormat.replace("y", dateTokens[0].slice(2,4)).replace("m", month).replace("d", day); }, convertToLocaleDateTime: function (stdDateTime) { // stdDateTime must be of the format "yyyy-MM-dd HH:mm:ss" // split the date and time. var tokens = stdDateTime.split(" "); // reassemble "date time" return this.convertToLocaleDate(tokens[0]) + " " + tokens[1]; } };