Who knew JavaScript thinks months are 0-offset? Fixes #14

This commit is contained in:
Samuel Cochran 2011-07-07 13:40:22 +08:00
parent d2bb7e8c66
commit 51e74fdac2
2 changed files with 2 additions and 2 deletions

View File

@ -47,7 +47,7 @@ class MailCatcher
parseDateRegexp: /^(\d{4})[-\/\\](\d{2})[-\/\\](\d{2})(?:\s+|T)(\d{2})[:-](\d{2})[:-](\d{2})(?:([ +-]\d{2}:\d{2}|\s*\S+|Z?))?$/
parseDate: (date) ->
if match = @parseDateRegexp.exec(date)
new Date match[1], match[2], match[3], match[4], match[5], match[6], 0
new Date match[1], match[2] - 1, match[3], match[4], match[5], match[6], 0
formatDate: (date) ->
date &&= @parseDate(date) if typeof(date) == "string"

View File

@ -63,7 +63,7 @@
MailCatcher.prototype.parseDate = function(date) {
var match;
if (match = this.parseDateRegexp.exec(date)) {
return new Date(match[1], match[2], match[3], match[4], match[5], match[6], 0);
return new Date(match[1], match[2] - 1, match[3], match[4], match[5], match[6], 0);
}
};
MailCatcher.prototype.formatDate = function(date) {