simple date problem, simple solution?

simple date problem, simple solution?

Post by iksraza » Fri, 03 Mar 2000 04:00:00



I can get the current time and date with gettime and strftime, this is
not a problem. What I also need is a way to calculate what the date is a
week from now. For instance, if my program happens to run on 03/30/2000.
I need to generate somehow a string that says 04/06/2000. Rolling my own
for this of course is possible, but this is such a common problem I
think their must be a common, tried and true solution. With the
structure vars (I'm talking about a C or C++ solution) I can increment
the day, but is there an easy way for me to program the logic that the
month or year may need to roll up as well?

Thanks in advance for all inqueries.

Iksrazal.

--
"That vulnerability is completely theoretical." -- Microsoft

 
 
 

simple date problem, simple solution?

Post by Russell Mar » Mon, 06 Mar 2000 04:00:00


Quote:> I can get the current time and date with gettime and strftime, this is
> not a problem. What I also need is a way to calculate what the date is a
> week from now. For instance, if my program happens to run on 03/30/2000.
> I need to generate somehow a string that says 04/06/2000. Rolling my own
> for this of course is possible, but this is such a common problem I
> think their must be a common, tried and true solution. With the
> structure vars (I'm talking about a C or C++ solution) I can increment
> the day, but is there an easy way for me to program the logic that the
> month or year may need to roll up as well?

Get a `now' time_t, add 7*86400, and convert as appropriate. I think
the functions you'd want, in order, are probably:

time()
(add the week here)
localtime()
strftime()

The main problem with the above approach is, what if the day isn't
exactly 86400 seconds long? [1] That is, what about leap seconds? I
suspect you won't consider this a serious problem, especially if
you're only after the date, but I thought I'd mention it. :-)

-Rus.

[1] Not that any day truly is, but you know what I mean :-)

 
 
 

1. A simple re-write problem--need a solution..

I have been trying to solve the following problem with mod_rewrite but with
no success.

/HelloWorld?FirstVar=xx

to

/cgi-bin/NewHelloWorld?NewVar=11&FirstVar=xx

The first URL should be "re-written" to the new one. Also the "FirstVar=xx"
is an optional param (where xx can be any number or text)

I have tried a lot of combinations and looked at your Re-Write Guide but
couldn't come up with a solution.

I thought I could it with RedirectMatch but couldn't and tried doing it with
mod_rewrite. Any solutions ..

Thanks
--Sri

Sent via Deja.com http://www.deja.com/
Before you buy.

2. FS Check problem? Help ?

3. Simple solution to "small BIOS vs. big HD" problem

4. Setting parameters for hardware temperatures and voltages

5. It seems that linux does not have a solution for a very simple problem!!

6. hi

7. Iomega Zip and PAS 16 SCSI: workable?

8. A simple question deserving a simple answer

9. a simple sed question ( there all simple :> )

10. Simple question from simple user

11. Simple FTP question (very simple)

12. Simple sh script, simple error?