This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Add integers to given date?


Can someone suggest a method to add a number of days to a given date in c or
c++? I have been unable to find any approach that does this even after
reading about 6 different how-to books on c and c++.

What I have found are ways to report the present date and time with the
"time.h" functions and calculate the difference in two times/dates.  I don't
need that.

I only need to start with a given date and add an integer to it, giving a
result.  For example, to calculate and output "the report is due on mmm, dd,
yyyy" (being 14 days from the given date). I have read it reported that
manipulation of dates is difficult to do in a command line environment.  I
can't believe that.

Do I need to define a class, a structure?   All suggestions would be
appreciated.

I recall that Visual Basic had a built-in function called something like
adddate or dateadd which did exactly what I am trying to do and in fact
could take string input of the date and add integers to it, outputting a new
string result.  The same thing is probably possible using some built in
"extra" features of Visual C++.  But my question is can this be done
(elegantly or crudely - I don't care) using the c or c++ language and the
gnu compiler?

Thanks,


Vince






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]