Handle time strings with timezone suffix
diff --git a/parsemail.go b/parsemail.go
index 996e357..d526dd7 100644
--- a/parsemail.go
+++ b/parsemail.go
@@ -9,6 +9,7 @@
"mime"
"mime/multipart"
"net/mail"
+ "regexp"
"strings"
"time"
)
@@ -375,6 +376,8 @@
return
}
+var timezoneRegex = regexp.MustCompile(` \([A-Za-z0-9]+\)$`)
+
func (hp headerParser) parseTime(s string) (t time.Time) {
if hp.err != nil || s == "" {
return
@@ -385,6 +388,8 @@
return t
}
+ s = timezoneRegex.ReplaceAllString(s, "")
+
t, hp.err = time.Parse("Mon, 2 Jan 2006 15:04:05 -0700", s)
return