Sub GetDaysInMonth (Month As Int, Year As Int, RequiredDayOfWeek As Int) As List
Dim res As List
res.Initialize
Dim firstday As Long = DateUtils.SetDate(Year, Month, 1)
Dim firstdayInWeek As Int = DateTime.GetDayOfWeek(firstday)
Dim p As Period
p.Days = (7 + RequiredDayOfWeek - firstdayInWeek) Mod 7
Dim GoodDay As Long = DateUtils.AddPeriod(firstday, p)
p.Days = 7
Do While DateTime.GetMonth(GoodDay) = Month
res.Add(GoodDay)
GoodDay = DateUtils.AddPeriod(GoodDay, p)
Loop
Return res
End Sub