Created
March 16, 2012 11:17
-
-
Save SamWM/2049643 to your computer and use it in GitHub Desktop.
Show dates a year before and after current date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DateTime currentDate = DateTime.Now; | |
DateTime loopDate; | |
for (loopDate = currentDate.AddMonths(-11); (loopDate - currentDate).Days < 365; loopDate = loopDate.AddMonths(1)) | |
{ | |
if(loopDate == currentDate) | |
{ | |
Console.Write("<<"); | |
} | |
Console.Write(loopDate.ToString("MMMM yyyy")); | |
if(loopDate == currentDate) | |
{ | |
Console.Write(">>"); | |
} | |
Console.Write(Environment.NewLine); | |
} | |
Console.ReadLine(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment