Add birthday filters
This commit is contained in:
parent
5812505763
commit
c617fe2505
1 changed files with 42 additions and 0 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue