Day-of-the-Year Calculation

Today is May 1st. It’s the 121st day of the year 2017. In 2016, May 1 was the 122nd day of the year, because 2016 was a leap year. You can look up this information on a calendar or, more disappointingly, use Google. You can also write code that does the calculation for you, which is this month’s Exercise.

Here’s the task: Given a random value from 1 to 365, which represents a day of the year 2017, what is the specific month and day for that value?

So the value 1 would be January 1, 2017. And the value 365 would be December 31, 2017. If the computer generates the value 211, what month and day would that be?

Don’t do the math in your head! Write code!

I’ll post my solution in a week.

Leave a Reply