How would one go about calculating a date from a day-number in C++? I don’t require you to write the whole code, I just can’t figure out the maths to calculate the month and the day-of-month!
Example:
input: 1
output: 01/01/2012
input: 10
output: 01/10/2012
input: 365
output: 12/31/2012
It would always use the current year, if they exceeded 365, I would return 0. There is no need for a leap-year detection.
Use a date calc library as e.g. the fine Boost Date_Time library with which this becomes