Bug fixes.

This commit is contained in:
Arran Ubels 2023-02-15 15:56:17 +11:00
parent a8e238d5d1
commit e654ac7b35
No known key found for this signature in database
GPG Key ID: 135EDC7B21D17F48

View File

@ -178,7 +178,6 @@ func ParseIn(datestr string, loc *time.Location, opts ...ParserOption) (time.Tim
// Equivalent to:
//
// t, err := dateparse.ParseIn("3/1/2014", denverLoc)
//
func ParseLocal(datestr string, opts ...ParserOption) (time.Time, error) {
p, err := parseTime(datestr, time.Local, opts...)
if err != nil {
@ -206,7 +205,6 @@ func MustParse(datestr string, opts ...ParserOption) time.Time {
//
// layout, err := dateparse.ParseFormat("2013-02-01 00:00:00")
// // layout = "2006-01-02 15:04:05"
//
func ParseFormat(datestr string, opts ...ParserOption) (string, error) {
p, err := parseTime(datestr, nil, opts...)
if err != nil {
@ -2022,10 +2020,10 @@ func newParser(dateStr string, loc *time.Location, opts ...ParserOption) (*parse
// allow the options to mutate the parser fields from their defaults
for _, option := range opts {
if err := option(p); err != nil {
return nil, fmt.Sprintf("option error: %w", err)
return nil, fmt.Errorf("option error: %w", err)
}
}
return p
return p, nil
}
func (p *parser) nextIs(i int, b byte) bool {