mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
Add must parse
This commit is contained in:
parent
7f3c0fde2f
commit
352f0d7149
@ -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) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user