chore: merge backend repo history into monorepo at backend/
git-subtree-dir: backend git-subtree-mainline:dc11190527git-subtree-split:acae976622
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user