Skip to content

Instantly share code, notes, and snippets.

@nameofSEOKWONHONG
Created October 17, 2021 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nameofSEOKWONHONG/1e60884b5479f216596da7802d7ebe6b to your computer and use it in GitHub Desktop.
Save nameofSEOKWONHONG/1e60884b5479f216596da7802d7ebe6b to your computer and use it in GitHub Desktop.
// See https://aka.ms/new-console-template for more information
Enumerable.Range(2021, 10).ToList().ForEach(year => {
Console.WriteLine($"==================={year}년=================");
Enumerable.Range(1, 12).ToList().ForEach(month => {
Console.WriteLine($"============={month}월==============");
var sday = new DateTime(year, month, 1);
var eday = sday.AddMonths(1).AddDays(-1);
int correctCnt = 0;
for(var i=eday.AddDays(-7); i<=eday; i = i.AddDays(1)) {
if(correctCnt == 0 && i.DayOfWeek == DayOfWeek.Wednesday) continue;
if(i.DayOfWeek == DayOfWeek.Wednesday) {
Console.WriteLine($"매월 마지막주 수요일 일자는:{i.ToString()}, {i.DayOfWeek.ToString()}");
correctCnt = 0;
return;
}
correctCnt+= 1;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment