mirror of
https://github.com/araddon/dateparse.git
synced 2025-01-19 03:06:11 +08:00
merge plus/minus state
This commit is contained in:
parent
47cec0dc4d
commit
91bb6b61cd
32
parseany.go
32
parseany.go
@ -35,8 +35,7 @@ const (
|
||||
ST_DIGITDASHT
|
||||
ST_DIGITDASHTZ
|
||||
ST_DIGITDASHTZDIGIT
|
||||
ST_DIGITDASHTDASH
|
||||
ST_DIGITDASHTPLUS
|
||||
ST_DIGITDASHTDELTA
|
||||
ST_DIGITCOMMA
|
||||
ST_DIGITCOLON
|
||||
ST_DIGITSLASH
|
||||
@ -220,10 +219,8 @@ iterRunes:
|
||||
// 2017-06-25T17:46:57.45706582-07:00
|
||||
// 2017-06-25T17:46:57+04:00
|
||||
switch {
|
||||
case r == '-':
|
||||
state = ST_DIGITDASHTDASH
|
||||
case r == '+':
|
||||
state = ST_DIGITDASHTPLUS
|
||||
case r == '-', r == '+':
|
||||
state = ST_DIGITDASHTDELTA
|
||||
case r == 'Z':
|
||||
state = ST_DIGITDASHTZ
|
||||
}
|
||||
@ -503,27 +500,16 @@ iterRunes:
|
||||
return time.Time{}, err
|
||||
}
|
||||
}
|
||||
case ST_DIGITDASHTDASH:
|
||||
// With another dash aka time-zone at end
|
||||
// 2006-01-02T15:04:05.999999999-07:00
|
||||
// 2006-01-02T15:04:05.99999999-07:00
|
||||
// 2006-01-02T15:04:05.9999999-07:00
|
||||
// 2006-01-02T15:04:05.999999-07:00
|
||||
// 2006-01-02T15:04:05.99999-07:00
|
||||
// 2006-01-02T15:04:05.9999-07:00
|
||||
// 2006-01-02T15:04:05.999-07:00
|
||||
// 2006-01-02T15:04:05.99-07:00
|
||||
if t, err := time.Parse("2006-01-02T15:04:05-07:00", datestr); err == nil {
|
||||
return t, nil
|
||||
} else {
|
||||
return time.Time{}, err
|
||||
}
|
||||
case ST_DIGITDASHTPLUS:
|
||||
// With a plus aka time-zone at end
|
||||
case ST_DIGITDASHTDELTA:
|
||||
// With another +/- time-zone at end
|
||||
// 2006-01-02T15:04:05.999999999+07:00
|
||||
// 2006-01-02T15:04:05.999999999-07:00
|
||||
// 2006-01-02T15:04:05.999999+07:00
|
||||
// 2006-01-02T15:04:05.999999-07:00
|
||||
// 2006-01-02T15:04:05.999+07:00
|
||||
// 2006-01-02T15:04:05.999-07:00
|
||||
// 2006-01-02T15:04:05+07:00
|
||||
// 2006-01-02T15:04:05-07:00
|
||||
if t, err := time.Parse("2006-01-02T15:04:05-07:00", datestr); err == nil {
|
||||
return t, nil
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user