//==================================================== file = gettime.c ===== //= A simple example of how to get the current time = //=========================================================================== //= Notes: = //= 1) Quantities in tm structure are on a 24-hour clock; day of month = //= (1 to 31), month (0 to 11), weekday (Sunday equals 0), year - = //= 1900, day of year (0 to 365), and a flag that is nonzero if = //= _daylight saving time is in effect. = //=-------------------------------------------------------------------------= //= Example execution: = //= = //= Local time is: Thu Jul 05 14:55:23 2007 = //= DST = 1 = //= Year day = 185 = //= Week day = 4 = //= Year = 107 = //= Month = 6 = //= Month day = 5 = //= Hour = 14 = //= Minutes = 55 = //= Seconds = 23 = //=-------------------------------------------------------------------------= //= Build: bcc32 gettime.c = //=-------------------------------------------------------------------------= //= Execute: gettime = //=-------------------------------------------------------------------------= //= Author: Ken Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=-------------------------------------------------------------------------= //= History: KJC (07/05/07) - Genesis (from Borland 5.02 help example) = //=========================================================================== //----- Include files ------------------------------------------------------- #include // Needed for printf() #include // Needed for time data structures and functions //=========================================================================== //= Main program = //=========================================================================== int main(void) { time_t timer; // Define the timer struct tm *tblock; // Define a structure for time block // Get time of day timer = time(NULL); // Converts date/time to a structure tblock = localtime(&timer); // Output ASCII data/time printf("Local time is: %s", asctime(tblock)); // Output members of tm structure printf("DST = %d \n", tblock->tm_isdst); printf("Year day = %d \n", tblock->tm_yday); printf("Week day = %d \n", tblock->tm_wday); printf("Year = %d \n", tblock->tm_year); printf("Month = %d \n", tblock->tm_mon); printf("Month day = %d \n", tblock->tm_mday); printf("Hour = %d \n", tblock->tm_hour); printf("Minutes = %d \n", tblock->tm_min); printf("Seconds = %d \n", tblock->tm_sec); return 0; }