Skip to content

Commit

Permalink
time string
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-bate committed Dec 7, 2023
1 parent 8736360 commit 71c49fa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions migrations/20231128_jellyfish_migration/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func getValidatedTime(bsonData bson.M, fieldName string) (time.Time, error) {
if valRaw, ok := bsonData[fieldName]; !ok {
return time.Time{}, errors.Newf("%s is missing", fieldName)
} else if val, ok := valRaw.(time.Time); !ok {
if tStr, ok := valRaw.(string); ok {
return time.Parse(time.RFC3339, tStr)
}
return time.Time{}, errors.Newf("%s is not of expected type", fieldName)
} else if val.IsZero() {
return time.Time{}, errors.Newf("%s is empty", fieldName)
Expand Down

0 comments on commit 71c49fa

Please sign in to comment.