By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

getDate function

P: 4
Hello. I am in need of a method to return the month and day of the month (as a birthday reminder for a friend...thought it'd be a nice little popup). I intend on using this as a comparison,

if ( getdate("%m") == "05" && getdate("%d") == "08" )
...birthday message code...

at least, it looked this easy from from the time.h library. Can someone please guide me as to the correct procedure?

And while I'm here, I may as well ask: what method should I use to have the program add itself to autostart on startup? Want it to be a nice birthday surprise. :)
Mar 10 '07 #1
Share this Question
Share on Google+
6 Replies


DeMan
100+
P: 1,806
if ( getdate("%m") == "05" && getdate("%d") == "08" )
...birthday message code...

at least, it looked this easy from from the time.h library. Can someone please guide me as to the correct procedure?
I think you'll find that getDate takes as argument a value of seconds since sometime (probably 01/01/1976 or something) and returns a structure containing elements representing month year etc. (you can use time() to get this value for right now, and pass that into getDate());

as for setting something to run automatically....Can't help you there I'm afraid....
Mar 10 '07 #2

P: 4
I think you'll find that getDate takes as argument a value of seconds since sometime (probably 01/01/1976 or something) and returns a structure containing elements representing month year etc. (you can use time() to get this value for right now, and pass that into getDate());

as for setting something to run automatically....Can't help you there I'm afraid....
so something like getDate(time(pointer_to_structure)) ?

(as you can see, I'm overtly simple and like to do things the easy way)

if not then surely..

(declare pointer)

int date = time(pointer_to_structure);

getDate(date);
Mar 10 '07 #3

DeMan
100+
P: 1,806
Sorry, I'm not sure the name of the exact structure, so I'll call it dateStruct here (lookup "date time c" or similar (in google or equiv) for better explanation)....

dateStruct myDate = getDate(time());

then myDate has fields that relate to month, day, year etc whcih you can compare to ....

(you may need to include some other libraries, but your search should clarify this)
Mar 11 '07 #4

P: 4
Sorry, I'm not sure the name of the exact structure, so I'll call it dateStruct here (lookup "date time c" or similar (in google or equiv) for better explanation)....

dateStruct myDate = getDate(time());

then myDate has fields that relate to month, day, year etc whcih you can compare to ....

(you may need to include some other libraries, but your search should clarify this)

I see..that helps tremendously. Otherwise I might've got the whole thing wrong again. Thank you for your help.
Mar 11 '07 #5

P: 4
....discovered the "_strdate()"

#include <iostream>
#include <ctime>

using namespace std;

int main(){
char date[9];
_strdate(date);
if ( date == "05/08/07" ){
cout << "Happy Birthday!";
}
cin.get();
}
Mar 11 '07 #6

DeMan
100+
P: 1,806
Good Stuff!!
Mar 11 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.