0
comment
comment
on 12/8/2014 11:20 PM
Rosetta Code has a number of programming tasks with example solutions in multiple languages. One of those tasks is find the last Sunday of each month. Here’s a sample in C#: DateTime date;
for (int i = 1; i <= 12; i++)
{
date = new DateTime(year, i, DateTime.DaysInMonth(year, i), System.Globalization.CultureInfo.CurrentCulture.Calendar);
while (date.DayOfWeek != DayOfWeek.Sunday)
{
date = date.AddDays(-1);
}
Console.WriteLine(date.ToString("yyyy-MM-dd"));
}
I thought it might be fun [...]