mirror of
https://github.com/araddon/dateparse.git
synced 2024-11-10 11:51:54 +08:00
doc some notes, and fix utf multi byte reads
This commit is contained in:
parent
34163bbbdb
commit
e3ddfb42a9
10
parseany.go
10
parseany.go
@ -40,11 +40,17 @@ func ParseAny(datestr string) (time.Time, error) {
|
||||
|
||||
state := ST_START
|
||||
|
||||
// General strategy is to read rune by rune through the date looking for
|
||||
// certain hints of what type of date we are dealing with.
|
||||
// Hopefully we only need to read about 5 or 6 bytes before
|
||||
// we figure it out and then attempt a parse
|
||||
iterRunes:
|
||||
for i := 0; i < len(datestr); i++ {
|
||||
r, _ := utf8.DecodeRuneInString(datestr[i:])
|
||||
r, bytesConsumed := utf8.DecodeRuneInString(datestr[i:])
|
||||
if bytesConsumed > 1 {
|
||||
i += (bytesConsumed - 1)
|
||||
}
|
||||
|
||||
//u.Infof("r=%s st=%d ", string(r), state)
|
||||
switch state {
|
||||
case ST_START:
|
||||
if unicode.IsDigit(r) {
|
||||
|
Loading…
Reference in New Issue
Block a user