public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Add integers to given date?
@ 1999-11-06 15:30 Vince O'Brien
  1999-11-06 16:03 ` Tim Prince
  1999-11-30 23:28 ` Vince O'Brien
  0 siblings, 2 replies; 4+ messages in thread
From: Vince O'Brien @ 1999-11-06 15:30 UTC (permalink / raw)
  To: help-gcc

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Add integers to given date?
  1999-11-06 15:30 Add integers to given date? Vince O'Brien
@ 1999-11-06 16:03 ` Tim Prince
  1999-11-30 23:28   ` Tim Prince
  1999-11-30 23:28 ` Vince O'Brien
  1 sibling, 1 reply; 4+ messages in thread
From: Tim Prince @ 1999-11-06 16:03 UTC (permalink / raw)
  To: help-gcc

>a method to add a number of days to a given date in c

from Plauger, "The Standard C Library,"

"..the only reliable way to modify a calendar time is to convert it to a
broken-down time by calling localtime(), modify the appropriate members, then
convert the result back to a calendar time by calling mktime()."

So I hope that someone can explain a good way around this problem.
Tim Prince
tprince@computer.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Add integers to given date?
  1999-11-06 15:30 Add integers to given date? Vince O'Brien
  1999-11-06 16:03 ` Tim Prince
@ 1999-11-30 23:28 ` Vince O'Brien
  1 sibling, 0 replies; 4+ messages in thread
From: Vince O'Brien @ 1999-11-30 23:28 UTC (permalink / raw)
  To: help-gcc

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Add integers to given date?
  1999-11-06 16:03 ` Tim Prince
@ 1999-11-30 23:28   ` Tim Prince
  0 siblings, 0 replies; 4+ messages in thread
From: Tim Prince @ 1999-11-30 23:28 UTC (permalink / raw)
  To: help-gcc

>a method to add a number of days to a given date in c

from Plauger, "The Standard C Library,"

"..the only reliable way to modify a calendar time is to convert it to a
broken-down time by calling localtime(), modify the appropriate members, then
convert the result back to a calendar time by calling mktime()."

So I hope that someone can explain a good way around this problem.
Tim Prince
tprince@computer.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-11-30 23:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-06 15:30 Add integers to given date? Vince O'Brien
1999-11-06 16:03 ` Tim Prince
1999-11-30 23:28   ` Tim Prince
1999-11-30 23:28 ` Vince O'Brien

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).