LoadIDs use time.UnixNanoseconds instead of GenUUID

This commit is contained in:
TeoV
2019-04-04 15:03:07 +03:00
committed by Dan Christian Bogos
parent 01857c4d8a
commit 93cb87bece
21 changed files with 174 additions and 53 deletions

View File

@@ -186,6 +186,7 @@ func ParseTimeDetectLayout(tmStr string, timezone string) (time.Time, error) {
astTimestamp := regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d*[+,-]\d+$`)
unixTimestampRule := regexp.MustCompile(`^\d{10}$`)
unixTimestampMilisecondsRule := regexp.MustCompile(`^\d{13}$`)
unixTimestampNanosecondsRule := regexp.MustCompile(`^\d{19}$`)
oneLineTimestampRule := regexp.MustCompile(`^\d{14}$`)
oneSpaceTimestampRule := regexp.MustCompile(`^\d{2}\.\d{2}.\d{4}\s{1}\d{2}:\d{2}:\d{2}$`)
eamonTimestampRule := regexp.MustCompile(`^\d{2}/\d{2}/\d{4}\s{1}\d{2}:\d{2}:\d{2}$`)
@@ -237,6 +238,12 @@ func ParseTimeDetectLayout(tmStr string, timezone string) (time.Time, error) {
} else {
return time.Unix(0, tmstmp*int64(time.Millisecond)).In(loc), nil
}
case unixTimestampNanosecondsRule.MatchString(tmStr):
if tmstmp, err := strconv.ParseInt(tmStr, 10, 64); err != nil {
return nilTime, err
} else {
return time.Unix(0, tmstmp).In(loc), nil
}
case tmStr == "0" || len(tmStr) == 0: // Time probably missing from request
return nilTime, nil
case oneLineTimestampRule.MatchString(tmStr):