Leap year programming questions

I received two notes on this happy leap day that there was a problem someone was having in with accounting for leap years in their code.  Both were quickly solved.

The first was programming for a leap year that turned out to be a common problem.  The programmer was checking for leap year by dividing the year evenly by 4, and seeing an error when looking at historical transactions in 1900 and 2000.  Centennial leap years can only be evenly divided by 400.

The other was with the use of the ATL COleDateTime API related to handling leap years in Visual Studio and .NET Framework.  It turned out that the workaround referenced in this article on Connect solved the issue: http://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=98949

Tags: leap year, Visual Studio.

1 thought on “Leap year programming questions”

Comments are closed.