Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion time/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,15 @@ func TestCalculateAge(t *testing.T) {
{
name: "Birthday not yet reached this year",
args: args{
birthDate: time.Date(testTime.Year()-25, testTime.Month()%12+1, testTime.Day(), 0, 0, 0, 0, time.UTC),
birthDate: func() time.Time {
futureMonth := testTime.Month() + 1
year := testTime.Year() - 25
if futureMonth > 12 {
futureMonth = 1
year++ // If we overflow to next year, change birth year
}
return time.Date(year, futureMonth, testTime.Day(), 0, 0, 0, 0, time.UTC)
}(),
},
want: 24,
},
Expand Down