Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Comparing dates?

 
Post new topic   Reply to topic Printable version
 View previous topic  Mervbot c->final Post :: Post MERVBot sending checksum errors?  View next topic  
Author Message
Maverick
broken record


Age:40
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Sun Feb 27, 2005 1:48 pm    Post subject: Comparing dates? Reply to topic Reply with quote

Ok I got a small challenge for all interested people tongue.gif

I am making a bot that stores date&time in a file. I can get this from the file and into a String.
Now I need to compare this date&time and compare it to the current date&time. I need to get the difference between the two and get the number of days that have passed.

I am trying to do it myself, searched everywhere but couldn't find a good example or explenation anywhere icon_sad.gif so I'm asking the experts here for help.

It seems like that CTime isn't supported so I have to do it with time_t . (Since Mervbot doesn't use MFC)

Can someone help me by posting some example code or send me in the correct direction?

Thanks icon_smile.gif
_________________
Nickname: Maverick (I changed my name!)
TWCore developer | Subspace statistics
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
50% Packetloss
Server Help Squatter


Age:40
Gender:Gender:Male
Joined: Sep 09 2003
Posts: 561
Location: Santa Clarita, California
Offline

PostPosted: Sun Feb 27, 2005 2:23 pm    Post subject: Reply to topic Reply with quote

http://www.cplusplus.com/ref/ctime/
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Maverick
broken record


Age:40
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Sun Feb 27, 2005 2:34 pm    Post subject: Reply to topic Reply with quote

50% Packetloss wrote:
http://www.cplusplus.com/ref/ctime/
Yes I looked there already but only problem is that I need to store the time.
I do this via a string. However there is no method available for converting a string into a time_t value.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Sun Feb 27, 2005 2:34 pm    Post subject: Reply to topic Reply with quote

Store it as binary?
Back to top
View users profile Send private message Add User to Ignore List
Maverick
broken record


Age:40
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Sun Feb 27, 2005 2:39 pm    Post subject: Reply to topic Reply with quote

Solo Ace wrote:
Store it as binary?
in a .ini? You show me how tongue.gif
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:41
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3615
Location: Las Vegas
Offline

PostPosted: Sun Feb 27, 2005 3:10 pm    Post subject: Reply to topic Reply with quote

Maverick wrote:
in a .ini? You show me how :P

fprintf(FILE, "%d\n", ctime_value);

Its only an integer.
Back to top
View users profile Send private message Add User to Ignore List Send email
Maverick
broken record


Age:40
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Sun Feb 27, 2005 3:44 pm    Post subject: Reply to topic Reply with quote

but how can you get that back into time_t value?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sun Feb 27, 2005 4:58 pm    Post subject: Reply to topic Reply with quote

You can use mktime to turn this tm structure:
Code: Show/Hide
typedef struct {
   int tm_hour;   /* hour (0 - 23) */
   int tm_isdst;  /* daylight saving time enabled/disabled */
   int tm_mday;   /* day of month (1 - 31) */
   int tm_min;    /* minutes (0 - 59) */
   int tm_mon;    /* month (0 - 11 : 0 = January) */
   int tm_sec;    /* seconds (0 - 59) */
   int tm_wday;   /* Day of week (0 - 6 : 0 = Sunday) */
   int tm_yday;   /* Day of year (0 - 365) */
   int tm_year;   /* Year less 1900 */
}


into a time_t
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Sun Feb 27, 2005 10:39 pm    Post subject: Reply to topic Reply with quote

No, just use MGB's way of doing it. That will automatically store it as a time_t.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Maverick
broken record


Age:40
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Mon Feb 28, 2005 5:12 am    Post subject: Reply to topic Reply with quote

OK I will try that.

Thanks for your help, guys icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Maverick
broken record


Age:40
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Mon Feb 28, 2005 4:34 pm    Post subject: Reply to topic Reply with quote

OMG you guys are awesome.. IT WORKS! biggrin.gif

Woo many thanks grav_cool-hands.gif
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:37
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Mon Feb 28, 2005 5:08 pm    Post subject: Reply to topic Reply with quote

Meh, whut evar!
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 165 page(s) served in previous 5 minutes.

phpBB Created this page in 0.436732 seconds : 36 queries executed (93.0%): GZIP compression disabled