Skip to content

Commit

Permalink
tmp: log birthdate
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Feb 21, 2024
1 parent 9b83a74 commit 7b8eaf5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app/utils/pet/pet.utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ func parseDate(dateStr string) (time.Time, error) {
}

func filterAge(pet *pet.Pet, minAge, maxAge int32) (bool, error) {
log.Info().
Str("service", "filterAge").
Str("module", "birth").Msgf("birthdate: %s", pet.Birthdate)
birthdate, err := parseDate(pet.Birthdate)
if err != nil {
return false, err
Expand All @@ -244,6 +247,9 @@ func filterAge(pet *pet.Pet, minAge, maxAge int32) (bool, error) {
currYear := time.Now()
birthYear := birthdate
diff := currYear.Sub(birthYear).Hours() / constant.DAY / constant.YEAR
log.Info().
Str("service", "filterAge").
Str("module", "FilterAge").Msgf("diff: %f", diff)

return diff >= float64(minAge) && diff <= float64(maxAge), nil
}

0 comments on commit 7b8eaf5

Please sign in to comment.