User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 403,518 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,844 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 141 | Replies: 3
Reply
Join Date: May 2008
Posts: 65
Reputation: FTProtocol has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Local timing

  #1  
Jul 17th, 2008
Is it possible to get the local time of a machine ( i can do this part ) then generate a random number between 1-5 ( i can do this ) then add the two together then execute a file when that time comes.

Like:

Local Time: 10:05
Random Number: 5
Time to Execute: 15:05 ( 3:05pm )

?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,411
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 21
Solved Threads: 389
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: Local timing

  #2  
Jul 18th, 2008
mktime() and localtime()
Both in <ctime>
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Join Date: May 2008
Posts: 65
Reputation: FTProtocol has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 1
FTProtocol FTProtocol is offline Offline
Junior Poster in Training

Re: Local timing

  #3  
Jul 18th, 2008
yes i know how to get the local time but are you able to add an int to it?

so if the local time is

03:15 ( 3:15 am ) and i add 5 to it, it becomes
08:15 ( 8:15 am )
Reply With Quote  
Join Date: Dec 2005
Posts: 3,411
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 21
Solved Threads: 389
Colleague
Salem's Avatar
Salem Salem is offline Offline
void main'ers are DOOMed

Re: Local timing

  #4  
Jul 18th, 2008
That's what mktime does - RTM.
localtime returns a struct tm
you then do tm->tm_hr += 5;
you then do mktime() on that to fix any day rollover (for example).
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
Do not PM me for help; You'll be ignored, or told to learn to read.
Do not ask me if I'm muslim - I'm not. Nor do I care about yours or anyone else's mysticism. Religion is a matrix, take the RED PILL.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 1:06 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC