dateparse
dateparse copied to clipboard
"1.jpg" is incorrectly matched as a date
The following code prints: Matched 1.jpg as date with format 1.jpg
layout, err := dateparse.ParseFormat("1.jpg")
if err == nil {
fmt.Printf("Matched %s as date with format %s", s, layout)
return true
}
Not sure this one is fixable or will be fixed, probably will close as wnf: https://play.golang.org/p/NY-m3OnWkKA
This really passes down to underlying go parser to determine correctness, it doesn't do a ton of additional error testing beyond validating it can parse it. Since go parser says that is a valid format, not sure this lib will attempt beyond that. open to arguments counter, but seems like an impossible chase to find invalid formats beyond that.
package main
import (
"fmt"
"time"
)
func main() {
t, err := time.ParseInLocation("1.jpg", "1.jpg", time.UTC)
fmt.Printf("hello t=%v IsZero()=%v err=%v", t, t.IsZero(), err)
}
@araddon Although it's sad, but it fits the module description:
About
GoLang Parse many date strings without knowing format in advance.
Maybe you could highlight in readme, that this package isn't able to detect if the string is a date string. It just parses strings that are a date string, but you just don't know the format.
It can be used for date string detection, but not without false positives. It should be said at laud.