diff --git a/public/javascripts/application.coffee b/public/javascripts/application.coffee index edb2bfb..5736dcc 100644 --- a/public/javascripts/application.coffee +++ b/public/javascripts/application.coffee @@ -57,8 +57,13 @@ class MailCatcher if match = @parseDateRegexp.exec(date) new Date match[1], match[2] - 1, match[3], match[4], match[5], match[6], 0 + offsetTimeZone: (date) -> + offset = Date.now().getTimezoneOffset()*60000 #convert timezone difference to milliseconds + date.setTime(date.getTime() - offset) + date + formatDate: (date) -> - date &&= @parseDate(date) if typeof(date) == "string" + date &&= @offsetTimeZone(@parseDate(date)) if typeof(date) == "string" date &&= date.toString("dddd, d MMM yyyy h:mm:ss tt") haveMessage: (message) -> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 301dcda..3f6ed89 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -79,8 +79,17 @@ } }; + MailCatcher.prototype.offsetTimeZone = function(date) { + var offset; + offset = Date.now().getTimezoneOffset() * 60000; + date.setTime(date.getTime() - offset); + return date; + }; + MailCatcher.prototype.formatDate = function(date) { - if (typeof date === "string") date && (date = this.parseDate(date)); + if (typeof date === "string") { + date && (date = this.offsetTimeZone(this.parseDate(date))); + } return date && (date = date.toString("dddd, d MMM yyyy h:mm:ss tt")); }; @@ -165,7 +174,6 @@ return $form = $iframe.find('form').submit(function(e) { e.preventDefault(); $(this).find('input[type="submit"]').attr('disabled', 'disabled').end().find('.loading').show(); - console.log($('#message iframe').contents().find('body')); return $('#message iframe').contents().find('body').xslt("/messages/" + id + "/analysis.xml", "/stylesheets/analysis.xsl"); }); } @@ -189,8 +197,8 @@ }; MailCatcher.prototype.subscribeWebSocket = function() { - var secure; - var _this = this; + var secure, + _this = this; secure = window.location.scheme === 'https'; this.websocket = new WebSocket("" + (secure ? 'wss' : 'ws') + "://" + window.location.host + "/messages"); return this.websocket.onmessage = function(event) {