From 352f0d71491b7b0b975c6ffcc774eeff085b44eb Mon Sep 17 00:00:00 2001 From: Aaron Raddon Date: Sun, 18 Sep 2016 11:46:39 -0700 Subject: [PATCH] Add must parse --- parseany.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/parseany.go b/parseany.go index 4bdcd54..5458575 100644 --- a/parseany.go +++ b/parseany.go @@ -47,6 +47,15 @@ var ( 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 func ParseAny(datestr string) (time.Time, error) {