From 2a5f7517f420dab359a07a1981caedab75be4c91 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Tue, 27 Aug 2024 14:59:17 +0300 Subject: [PATCH] add function to calculate age with yob --- internal/utils/age.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/utils/age.go b/internal/utils/age.go index 8d1aa24..6b040e7 100644 --- a/internal/utils/age.go +++ b/internal/utils/age.go @@ -19,4 +19,17 @@ func CalculateAge(birthdate, today time.Time) int { age-- } return age +} + +// CalculateAgeWithYOB calculates the age based on the given year of birth (YOB). +// It subtracts the YOB from the current year to determine the age. +// +// Parameters: +// yob: The year of birth as an integer. +// +// Returns: +// The calculated age as an integer. +func CalculateAgeWithYOB(yob int) int { + currentYear := time.Now().Year() + return currentYear - yob } \ No newline at end of file