about SYSTEMTIME
-
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!
-
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!
-
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."
-
yep. but watch for 25th hour an 61st minute ;-). I played with that stuff for an hour until I realized my horrible mistake :-)
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?
-
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?
if you look to the documentation for
SYSTEMTIME
: It is not recommended that you add and subtract values from theSYSTEMTIME
structure to obtain relative times. Instead, you should - Convert theSYSTEMTIME
structure to aFILETIME
structure. - Copy the resultingFILETIME
structure to aULARGE_INTEGER
structure. - Use normal 64-bit arithmetic on theULARGE_INTEGER
value. insteadLARGE_INTEGER
you can use the__int64
on microsoft compilers -
if you look to the documentation for
SYSTEMTIME
: It is not recommended that you add and subtract values from theSYSTEMTIME
structure to obtain relative times. Instead, you should - Convert theSYSTEMTIME
structure to aFILETIME
structure. - Copy the resultingFILETIME
structure to aULARGE_INTEGER
structure. - Use normal 64-bit arithmetic on theULARGE_INTEGER
value. insteadLARGE_INTEGER
you can use the__int64
on microsoft compilersSYSTEMTIME sysTime;
..
..
..
CTime tm (sysTime);tm += 60; // Adds one minute
tm += 3600 // Adds one hoursysTime.wYear = tm.GetYear();
sysTime.wMonth = tm.GetMonth();
sysTime.wDay..
sysTime..
sysTime.. -
if you look to the documentation for
SYSTEMTIME
: It is not recommended that you add and subtract values from theSYSTEMTIME
structure to obtain relative times. Instead, you should - Convert theSYSTEMTIME
structure to aFILETIME
structure. - Copy the resultingFILETIME
structure to aULARGE_INTEGER
structure. - Use normal 64-bit arithmetic on theULARGE_INTEGER
value. insteadLARGE_INTEGER
you can use the__int64
on microsoft compilersThanks for your help!
-
SYSTEMTIME sysTime;
..
..
..
CTime tm (sysTime);tm += 60; // Adds one minute
tm += 3600 // Adds one hoursysTime.wYear = tm.GetYear();
sysTime.wMonth = tm.GetMonth();
sysTime.wDay..
sysTime..
sysTime..Good It is very simple!!! Thank you!
-
SYSTEMTIME sysTime;
..
..
..
CTime tm (sysTime);tm += 60; // Adds one minute
tm += 3600 // Adds one hoursysTime.wYear = tm.GetYear();
sysTime.wMonth = tm.GetMonth();
sysTime.wDay..
sysTime..
sysTime..The following sentence can work well for your the last five sentences. tm.GetAsSystemTime(sysTime) :)