Skip to content

Commit

Permalink
time from millis
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Dec 7, 2023
1 parent 5b38ecc commit 1ff02a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ func (m *Migration) RunAndExit() {
if m.client != nil {
m.client.Disconnect(m.ctx)
}

os.Exit(1)
}
}
Expand Down
8 changes: 3 additions & 5 deletions migrations/20231128_jellyfish_migration/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ func GetValidatedString(bsonData bson.M, fieldName string) (string, error) {
func getValidatedTime(bsonData bson.M, fieldName string) (string, error) {
if valRaw, ok := bsonData[fieldName]; !ok {
return "", errors.Newf("%s is missing", fieldName)
} else if val, ok := valRaw.(string); !ok {
t, err := time.Parse(types.TimeFormat, val)
if err != nil {
return "", err
} else if ms, ok := valRaw.(int64); !ok {
if t := time.Unix(0, ms*int64(time.Millisecond)); !t.IsZero() {
return t.Format(types.TimeFormat), nil
}
return t.Format(types.TimeFormat), nil
}
log.Printf("invalid data %#v", bsonData)
return "", errors.Newf("%s is missing", fieldName)
Expand Down

0 comments on commit 1ff02a9

Please sign in to comment.