Files
chat_room/backend/internal/utils/age.go
T
mobiniqow 35f5084005 chore: merge backend repo history into monorepo at backend/
git-subtree-dir: backend
git-subtree-mainline: dc11190527
git-subtree-split: acae976622
2026-09-27 10:30:16 +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
}