Tuesday, July 28, 2009

C++ check time?

I am trying to make a program that checks if it is midnight, but I can't figure it out. I am using time.h. Can someone please post the code to check if it is midnight?

C++ check time?
#include %26lt;time.h%26gt;





bool isMidnight()


{


struct tm *newtime;


time_t long_time;





time( %26amp;long_time ); /* Get time as long integer. */


newtime = localtime( %26amp;long_time ); /* Convert to local time. */





bool bIsMidnight = (newtime-%26gt;tm_hour) == 0 %26amp;%26amp; (newtime-%26gt;tm_min == 0) %26amp;%26amp; (newtime-%26gt;tm_sec == 0);


return bIsMidnight;


}


No comments:

Post a Comment