Only do timezone offset if we have a date

This commit is contained in:
Samuel Cochran 2012-01-02 11:01:26 +08:00
parent 3d6f2a4b6a
commit 1e717a7d76
2 changed files with 7 additions and 7 deletions

View File

@ -58,12 +58,13 @@ class MailCatcher
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
offset = Date.now().getTimezoneOffset() * 60000 #convert timezone difference to milliseconds
date.setTime(date.getTime() - offset)
date
formatDate: (date) ->
date &&= @offsetTimeZone(@parseDate(date)) if typeof(date) == "string"
date &&= @parseDate(date) if typeof(date) == "string"
date &&= @offsetTimeZone(date)
date &&= date.toString("dddd, d MMM yyyy h:mm:ss tt")
haveMessage: (message) ->

View File

@ -87,9 +87,8 @@
};
MailCatcher.prototype.formatDate = function(date) {
if (typeof date === "string") {
date && (date = this.offsetTimeZone(this.parseDate(date)));
}
if (typeof date === "string") date && (date = this.parseDate(date));
date && (date = this.offsetTimeZone(date));
return date && (date = date.toString("dddd, d MMM yyyy h:mm:ss tt"));
};
@ -197,8 +196,8 @@
};
MailCatcher.prototype.subscribeWebSocket = function() {
var secure,
_this = this;
var secure;
var _this = this;
secure = window.location.scheme === 'https';
this.websocket = new WebSocket("" + (secure ? 'wss' : 'ws') + "://" + window.location.host + "/messages");
return this.websocket.onmessage = function(event) {