mktime
Converts the time information in a structure into calendar time
#include <time.h> time_t mktime ( struct tm *timeptr);
Returns the converted calendar time. On error, -1 will be returned cast as type (time_t). To test for an error condition, compare the return value to (time_t) -1.
mktime converts the time information in the structure pointed to by the timeptr parameter into a calendar time with the same encoding used by the time function.
asctime, asctime_r, clock, ctime, ctime_r, difftime, gmtime, gmtime_r, localtime, localtime_r, strftime, time
#include <stdio.h> #include <time.h> static const char *week_day[ ] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; main () { struct tm new_year; new_year.tm_year = 2001 - 1900; new_year.tm_mon = 0; new_year.tm_mday = 1; new_year.tm_hour = 0; new_year.tm_min = 0; new_year.tm_sec = 0; new_year.tm_isdst = 0; mktime (&new_year); printf ("The next century begins on a %s\n", week_day [new_year.tm_wday] ); }
produces the following:
The next century begins on a Monday