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. about SYSTEMTIME

about SYSTEMTIME

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
9 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.
  • F Offline
    F Offline
    FlyingDancer
    wrote on last edited by
    #1

    I declared a varible as a SYSTEMTIME type in my code as: SYSTEMTIME st; how to make its value one minute later or one hour later? Thank you in advance!

    T 1 Reply Last reply
    0
    • F FlyingDancer

      I declared a varible as a SYSTEMTIME type in my code as: SYSTEMTIME st; how to make its value one minute later or one hour later? Thank you in advance!

      T Offline
      T Offline
      thowra
      wrote on last edited by
      #2

      st.wMinute += 1;

      or

      st.wHour += 1;

      "The folly of man is that he dreams of what he can never achieve rather than dream of what he can." "If you think education is expensive, try ignorance."

      G 1 Reply Last reply
      0
      • T thowra

        st.wMinute += 1;

        or

        st.wHour += 1;

        "The folly of man is that he dreams of what he can never achieve rather than dream of what he can." "If you think education is expensive, try ignorance."

        G Offline
        G Offline
        geo_m
        wrote on last edited by
        #3

        yep. but watch for 25th hour an 61st minute ;-). I played with that stuff for an hour until I realized my horrible mistake :-)

        F 1 Reply Last reply
        0
        • G geo_m

          yep. but watch for 25th hour an 61st minute ;-). I played with that stuff for an hour until I realized my horrible mistake :-)

          F Offline
          F Offline
          FlyingDancer
          wrote on last edited by
          #4

          That sounds a little difficult,I think. You should care about many things, such as the rolling-over problem, including second to minute,minute to hour,hour to day, day to month, month to year and so on, in which you should also consider the leap problem, whether there are 28 days, 29 days, 30 days, or 31 days in a month. Can you bring out a better way? Here is one I can't still have enough condidence. Convert the varible into a FILETIME or LARGE_INTEGER varible, and then increase the new varible's value. At last convert the varible back. Herein we know "FILETIME structure is defined as a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601", however I don't know the definition of LARGE_INTEGER Can somebody tell me some better ways or my last quetion?

          G 1 Reply Last reply
          0
          • F FlyingDancer

            That sounds a little difficult,I think. You should care about many things, such as the rolling-over problem, including second to minute,minute to hour,hour to day, day to month, month to year and so on, in which you should also consider the leap problem, whether there are 28 days, 29 days, 30 days, or 31 days in a month. Can you bring out a better way? Here is one I can't still have enough condidence. Convert the varible into a FILETIME or LARGE_INTEGER varible, and then increase the new varible's value. At last convert the varible back. Herein we know "FILETIME structure is defined as a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601", however I don't know the definition of LARGE_INTEGER Can somebody tell me some better ways or my last quetion?

            G Offline
            G Offline
            geo_m
            wrote on last edited by
            #5

            if you look to the documentation for SYSTEMTIME: It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should - Convert the SYSTEMTIME structure to a FILETIME structure. - Copy the resulting FILETIME structure to a ULARGE_INTEGER structure. - Use normal 64-bit arithmetic on the ULARGE_INTEGER value. instead LARGE_INTEGER you can use the __int64 on microsoft compilers

            V F 2 Replies Last reply
            0
            • G geo_m

              if you look to the documentation for SYSTEMTIME: It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should - Convert the SYSTEMTIME structure to a FILETIME structure. - Copy the resulting FILETIME structure to a ULARGE_INTEGER structure. - Use normal 64-bit arithmetic on the ULARGE_INTEGER value. instead LARGE_INTEGER you can use the __int64 on microsoft compilers

              V Offline
              V Offline
              vcplusplus
              wrote on last edited by
              #6

              SYSTEMTIME sysTime;
              ..
              ..
              ..
              CTime tm (sysTime);

              tm += 60; // Adds one minute
              tm += 3600 // Adds one hour

              sysTime.wYear = tm.GetYear();
              sysTime.wMonth = tm.GetMonth();
              sysTime.wDay..
              sysTime..
              sysTime..

              F 2 Replies Last reply
              0
              • G geo_m

                if you look to the documentation for SYSTEMTIME: It is not recommended that you add and subtract values from the SYSTEMTIME structure to obtain relative times. Instead, you should - Convert the SYSTEMTIME structure to a FILETIME structure. - Copy the resulting FILETIME structure to a ULARGE_INTEGER structure. - Use normal 64-bit arithmetic on the ULARGE_INTEGER value. instead LARGE_INTEGER you can use the __int64 on microsoft compilers

                F Offline
                F Offline
                FlyingDancer
                wrote on last edited by
                #7

                Thanks for your help!

                1 Reply Last reply
                0
                • V vcplusplus

                  SYSTEMTIME sysTime;
                  ..
                  ..
                  ..
                  CTime tm (sysTime);

                  tm += 60; // Adds one minute
                  tm += 3600 // Adds one hour

                  sysTime.wYear = tm.GetYear();
                  sysTime.wMonth = tm.GetMonth();
                  sysTime.wDay..
                  sysTime..
                  sysTime..

                  F Offline
                  F Offline
                  FlyingDancer
                  wrote on last edited by
                  #8

                  Good It is very simple!!! Thank you!

                  1 Reply Last reply
                  0
                  • V vcplusplus

                    SYSTEMTIME sysTime;
                    ..
                    ..
                    ..
                    CTime tm (sysTime);

                    tm += 60; // Adds one minute
                    tm += 3600 // Adds one hour

                    sysTime.wYear = tm.GetYear();
                    sysTime.wMonth = tm.GetMonth();
                    sysTime.wDay..
                    sysTime..
                    sysTime..

                    F Offline
                    F Offline
                    FlyingDancer
                    wrote on last edited by
                    #9

                    The following sentence can work well for your the last five sentences. tm.GetAsSystemTime(sysTime) :)

                    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