Date Calculator Problem

I'm trying to figure out a way to calculate a future date based on a given date and set amount of days to add.

For instance, if i have the date 02/06/2011 and want to add 1200 days to it. I would need to console to out put the new date.

Can someone give me some advice on what steps i should take to get this done?
Here is one way assuming "date" is a string. Convert the string to a time_t, add 1200 days worth of seconds to it, convert back to a string. You'll need the <ctime> header. C++ does not require the strptime() (parse time string) function, but many OSes provide it as the inverse of strftime().

strptime() -> struct tm -> mktime() -> date arithmetic -> gmtime()/localtime() -> strftime().

If you are expected to do all of the date calculations yourself (leap year conversion, etc.) then this method is inappropriate because it does all the work for you.
Hey PanGalactic, Thanks for the information. Do you happen to know of any reference i can use to do this conversion manually instead of using the functions?
This subject comes up frequently on this site. You could try searching for "julian day" on this site and on Wikipedia.
Topic archived. No new replies allowed.