I need to parse the date_id field from emails headers. However these seem to have slightly different layouts so I've started to build a switch case/block . I'm wondering if that's really the way to fix this issue.
case strings.Contains(h.Headers[bk].Date, "(CEST)"):
layout = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)"
case strings.Contains(h.Headers[bk].Date, "(EDT)"):
layout = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)"
default:
layout = "Mon, 02 Jan 2006 15:04:05 -0700"
}
You could use mail.Header
and simply call .Date()
on it.
Another option is to read the code starting from line 70 and write your own function.