Files
chat_room/internal/utils/age.go
T
mobiniqow 2823fb45f5 Initial commit: dating app backend (Go/Gin/GORM/Postgres)
Phone+OTP auth, staged onboarding, admin approval workflow, and a
full discovery/swipe/match/chat system with photo upload and
approximate distance (haversine) based on user location.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-15 23:23:47 +03:30

17 lines
391 B
Go

package utils
import "time"
// CalcAge سن رو از تاریخ تولد حساب می‌کنه (نسبت به الان)
func CalcAge(birthDate *time.Time) int {
if birthDate == nil {
return 0
}
now := time.Now()
age := now.Year() - birthDate.Year()
if now.Month() < birthDate.Month() || (now.Month() == birthDate.Month() && now.Day() < birthDate.Day()) {
age--
}
return age
}