Add must parse

This commit is contained in:
Aaron Raddon 2016-09-18 11:46:39 -07:00
parent 7f3c0fde2f
commit 352f0d7149

View File

@ -47,6 +47,15 @@ var (
weekdayAbbrev = map[string]bool{"Mon": true, "Tue": true, "Wed": true, "Thu": true, "Fri": true, "Sat": true, "Sun": true} weekdayAbbrev = map[string]bool{"Mon": true, "Tue": true, "Wed": true, "Thu": true, "Fri": true, "Sat": true, "Sun": true}
) )
// Parse a date, and panic if it can't be parsed
func MustParse(datestr string) time.Time {
t, err := ParseAny(datestr)
if err != nil {
panic(err.Error())
}
return t
}
// Given an unknown date format, detect the type, parse, return time // Given an unknown date format, detect the type, parse, return time
func ParseAny(datestr string) (time.Time, error) { func ParseAny(datestr string) (time.Time, error) {