Server Help

Bot Questions - Comparing dates?

Maverick - Sun Feb 27, 2005 1:48 pm
Post subject: Comparing dates?
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
50% Packetloss - Sun Feb 27, 2005 2:23 pm
Post subject:
http://www.cplusplus.com/ref/ctime/
Maverick - Sun Feb 27, 2005 2:34 pm
Post subject:
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.
Solo Ace - Sun Feb 27, 2005 2:34 pm
Post subject:
Store it as binary?
Maverick - Sun Feb 27, 2005 2:39 pm
Post subject:
Solo Ace wrote:
Store it as binary?
in a .ini? You show me how tongue.gif
Mine GO BOOM - Sun Feb 27, 2005 3:10 pm
Post subject:
Maverick wrote:
in a .ini? You show me how :P

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

Its only an integer.
Maverick - Sun Feb 27, 2005 3:44 pm
Post subject:
but how can you get that back into time_t value?
D1st0rt - Sun Feb 27, 2005 4:58 pm
Post subject:
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
Cyan~Fire - Sun Feb 27, 2005 10:39 pm
Post subject:
No, just use MGB's way of doing it. That will automatically store it as a time_t.
Maverick - Mon Feb 28, 2005 5:12 am
Post subject:
OK I will try that.

Thanks for your help, guys icon_smile.gif
Maverick - Mon Feb 28, 2005 4:34 pm
Post subject:
OMG you guys are awesome.. IT WORKS! biggrin.gif

Woo many thanks grav_cool-hands.gif
Solo Ace - Mon Feb 28, 2005 5:08 pm
Post subject:
Meh, whut evar!
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group