diff --git a/parseany.go b/parseany.go index 04f084a..0d0be2f 100644 --- a/parseany.go +++ b/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 {