getDate function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • soaring747
    New Member
    • Mar 2007
    • 4

    getDate function

    Hello. I am in need of a method to return the month and day of the month (as a birthday reminder for a friend...though t 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. :)
  • DeMan
    Top Contributor
    • Nov 2006
    • 1799

    #2
    Originally posted by soaring747
    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....

    Comment

    • soaring747
      New Member
      • Mar 2007
      • 4

      #3
      Originally posted by DeMan
      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(po inter_to_struct ure)) ?

      (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);

      Comment

      • DeMan
        Top Contributor
        • Nov 2006
        • 1799

        #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)

        Comment

        • soaring747
          New Member
          • Mar 2007
          • 4

          #5
          Originally posted by DeMan
          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.

          Comment

          • soaring747
            New Member
            • Mar 2007
            • 4

            #6
            ....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();
            }

            Comment

            • DeMan
              Top Contributor
              • Nov 2006
              • 1799

              #7
              Good Stuff!!

              Comment

              Working...