Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is there any API for Data?

Is there any API for Data?

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelptutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nandu_77b
    wrote on last edited by
    #1

    Hi, Is there any win32 API available for date calculation? All i need is, once the system date time is read (for EX: Mon, 10 Nov 2008 11:11:20) from this we need to add 72 hours, and the time after 72 hours should be Thu, 13-Nov-2008 12:11:20. I am able to get the current time from system. But i like to know how to calculate date and time after 72 hours. Is there any API available for this? Mon, 10 Nov 2008 11:11:20 - This I am able to get from system. Thu, 13-Nov-2008 12:11:20 - I need to calculate for this date and time (that I should after 72 hours) Can anyone help me in this regards. -Nanadu

    _ S 2 Replies Last reply
    0
    • N Nandu_77b

      Hi, Is there any win32 API available for date calculation? All i need is, once the system date time is read (for EX: Mon, 10 Nov 2008 11:11:20) from this we need to add 72 hours, and the time after 72 hours should be Thu, 13-Nov-2008 12:11:20. I am able to get the current time from system. But i like to know how to calculate date and time after 72 hours. Is there any API available for this? Mon, 10 Nov 2008 11:11:20 - This I am able to get from system. Thu, 13-Nov-2008 12:11:20 - I need to calculate for this date and time (that I should after 72 hours) Can anyone help me in this regards. -Nanadu

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      The solution is as follows.

      int main()
      {
          // Current date/time based on current system
          time_t now = time(0);
      	int number_minutes=72*60; // 72 HOURS
      
      	tm* localtm = localtime(&now);
          cout << "The local date and time is: " << asctime(localtm) << endl;
      
      	now += (60 * number_minutes);    //60secs * minutes
      
          struct tm* localtm_edited = localtime(&now);
      
              tm* localtm_edited = localtime(&now);
              cout <<"The local date and time  i is: "   << asctime(localtm_edited); // << endl;
          }
      
          return 0;
      }
      
      K N 2 Replies Last reply
      0
      • N Nandu_77b

        Hi, Is there any win32 API available for date calculation? All i need is, once the system date time is read (for EX: Mon, 10 Nov 2008 11:11:20) from this we need to add 72 hours, and the time after 72 hours should be Thu, 13-Nov-2008 12:11:20. I am able to get the current time from system. But i like to know how to calculate date and time after 72 hours. Is there any API available for this? Mon, 10 Nov 2008 11:11:20 - This I am able to get from system. Thu, 13-Nov-2008 12:11:20 - I need to calculate for this date and time (that I should after 72 hours) Can anyone help me in this regards. -Nanadu

        S Offline
        S Offline
        Saurabh Garg
        wrote on last edited by
        #3

        Just out of curiosity, why do you repeat same question 3 times :-) -Saurabh

        1 Reply Last reply
        0
        • _ _AnsHUMAN_

          The solution is as follows.

          int main()
          {
              // Current date/time based on current system
              time_t now = time(0);
          	int number_minutes=72*60; // 72 HOURS
          
          	tm* localtm = localtime(&now);
              cout << "The local date and time is: " << asctime(localtm) << endl;
          
          	now += (60 * number_minutes);    //60secs * minutes
          
              struct tm* localtm_edited = localtime(&now);
          
                  tm* localtm_edited = localtime(&now);
                  cout <<"The local date and time  i is: "   << asctime(localtm_edited); // << endl;
              }
          
              return 0;
          }
          
          K Offline
          K Offline
          kevinmengmsn
          wrote on last edited by
          #4

          the "localtm_edited" redefinition..:confused:

          _ 1 Reply Last reply
          0
          • K kevinmengmsn

            the "localtm_edited" redefinition..:confused:

            _ Offline
            _ Offline
            _AnsHUMAN_
            wrote on last edited by
            #5

            is there some error you get? Please check you have not define localtm_edited variable twice in your code.

            Some things seem HARD to do, until we know how to do them. ;-)_AnShUmAn_

            1 Reply Last reply
            0
            • _ _AnsHUMAN_

              The solution is as follows.

              int main()
              {
                  // Current date/time based on current system
                  time_t now = time(0);
              	int number_minutes=72*60; // 72 HOURS
              
              	tm* localtm = localtime(&now);
                  cout << "The local date and time is: " << asctime(localtm) << endl;
              
              	now += (60 * number_minutes);    //60secs * minutes
              
                  struct tm* localtm_edited = localtime(&now);
              
                      tm* localtm_edited = localtime(&now);
                      cout <<"The local date and time  i is: "   << asctime(localtm_edited); // << endl;
                  }
              
                  return 0;
              }
              
              N Offline
              N Offline
              Nandu_77b
              wrote on last edited by
              #6

              Thanks, its working fine. Similarly is there any way to give the time as input and get the out put calculated for next 72 hours. For Example in-put will in the format "Thu, 13 Nov 2008 12:11:20 GMT" and i need the out-put as "Mon, 10 Nov 2008 11:11:20 GMT", this is calculated for next 72. Is it possible to give in-time and get calculated for next 72 hours? -Nandu

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups