fix: set time format right (#17402)

This commit is contained in:
jiuker
2023-06-14 22:49:13 +08:00
committed by GitHub
parent 69f819e199
commit 0474791cf8
3 changed files with 14 additions and 7 deletions

View File

@@ -70,3 +70,13 @@ func ParseHeader(timeStr string) (time.Time, error) {
}
return time.Time{}, ErrMalformedDate
}
// ParseReplicationTS parse http.TimeFormat first
// will try time.RFC3339Nano when parse http.TimeFormat failed
func ParseReplicationTS(str string) (time.Time, error) {
tm, err := time.Parse(http.TimeFormat, str)
if tm.IsZero() || err != nil {
tm, err = time.Parse(time.RFC3339Nano, str)
}
return tm, err
}