diff --git a/const.go b/const.go index 3aa6dae..eee3f8e 100644 --- a/const.go +++ b/const.go @@ -319,14 +319,14 @@ const ( ) var ( - // ApplyTimeRegexp is a regular expression that matches various time formats such as: + // TimeFormatRegexp is a regular expression that matches various time formats such as: // 15:04:05, 15:04:05.000, 15:04:05.000000, 15, 2017-01-01 15:04, 2021-07-20T00:59:10Z, // 2021-07-20T00:59:10+08:00, 2021-07-20T00:00:10-07:00, etc. - ApplyTimeRegexp = regexp.MustCompile(`(\s+|^\s*|T)\d{1,2}((:\d{1,2})*|((:\d{1,2}){2}\.(\d{3}|\d{6}|\d{9})))(\s*$|[Z+-])`) + TimeFormatRegexp = regexp.MustCompile(`(\s+|^\s*|T)\d{1,2}((:\d{1,2})*|((:\d{1,2}){2}\.(\d{3}|\d{6}|\d{9})))(\s*$|[Z+-])`) - // OnlyTimeRegexp is a regular expression that matches time formats such as: + // TimeOnlyRegexp is a regular expression that matches time formats such as: // 15:04:05, 15, 15:04:05.000, 15:04:05.000000, etc. - OnlyTimeRegexp = regexp.MustCompile(`^\s*\d{1,2}((:\d{1,2})*|((:\d{1,2}){2}\.(\d{3}|\d{6}|\d{9})))\s*$`) + TimeOnlyRegexp = regexp.MustCompile(`^\s*\d{1,2}((:\d{1,2})*|((:\d{1,2}){2}\.(\d{3}|\d{6}|\d{9})))\s*$`) ) var ( diff --git a/time.go b/time.go index f933570..77ab3ca 100644 --- a/time.go +++ b/time.go @@ -623,8 +623,8 @@ func (t *Timex) Parse(s ...string) (value time.Time, err error) { ) for _, str := range s { - hasTimeInStr := ApplyTimeRegexp.MatchString(str) // match 15:04:05, 15 - onlyTimeInStr = hasTimeInStr && onlyTimeInStr && OnlyTimeRegexp.MatchString(str) + hasTimeInStr := TimeFormatRegexp.MatchString(str) // match 15:04:05, 15 + onlyTimeInStr = hasTimeInStr && onlyTimeInStr && TimeOnlyRegexp.MatchString(str) if value, err = t.parseWithFormat(str, currentLocation); err == nil { location := value.Location() parseTime = FormatTimex(value)