diff --git a/model/birthdays.go b/model/birthdays.go index c18b3f2..c1bd058 100644 --- a/model/birthdays.go +++ b/model/birthdays.go @@ -51,3 +51,45 @@ func NewBirthdayFromRecord(record []string) (*Birthday, error) { return b, nil } + +func FilterByYear(birthdays []*Birthday, year int) []*Birthday { + filteredBirthdays := []*Birthday{} + for _, birthday := range birthdays { + if birthday.YearOfBirth == year { + filteredBirthdays = append(filteredBirthdays, birthday) + } + } + return filteredBirthdays +} + +func FilterByMonth(birthdays []*Birthday, month int) []*Birthday { + filteredBirthdays := []*Birthday{} + for _, birthday := range birthdays { + if birthday.MonthOfBirth == month { + filteredBirthdays = append(filteredBirthdays, birthday) + } + } + return filteredBirthdays +} + +func FilterByDay(birthdays []*Birthday, day int) []*Birthday { + filteredBirthdays := []*Birthday{} + for _, birthday := range birthdays { + if birthday.DayOfBirth == day { + filteredBirthdays = append(filteredBirthdays, birthday) + } + } + return filteredBirthdays +} + +func FilterByDate(birthdays []*Birthday, day, month, year int) []*Birthday { + filteredBirthdays := []*Birthday{} + for _, birthday := range birthdays { + if birthday.DayOfBirth == day && + birthday.MonthOfBirth == month && + birthday.YearOfBirth == year { + filteredBirthdays = append(filteredBirthdays, birthday) + } + } + return filteredBirthdays +}