
mktime
7-41
Run-Time-Support Functions
Convert to Calendar Time
mktime
Syntax
#include <time.h>
time_t *
mktime
(struct tm *timeptr);
Defined in
mktime.c in rts.src
Description
The mktime function converts a broken-down time, expressed as local time,
into proper calendar time. The timeptr argument points to a structure that holds
the broken-down time.
The function ignores the original values of tm_wday and tm_yday and does not
restrict the other values in the structure. After successful completion of time
conversions, tm_wday and tm_yday are set appropriately and the other com-
ponents in the structure have values within the restricted ranges. The final
value of tm_mday is not sent until tm_mon and tm_year are determined.
The return value is encoded as a value of type time_t. If the calendar time
cannot be represented, the function returns the value
−
1.
For more information about the functions and types that the time.h header
declares and defines, see subsection 7.2.12,
Time Functions (time.h)
, on
Example
This example determines the day of the week that July 4, 2001 falls on.
#include <time.h>
static const char *const wday[] = {
”Sunday”, ”Monday”, ”Tuesday”, ”Wednesday”,
”Thursday”, ”Friday”, ”Saturday” };
struct tm time_str;
time_str.tm_year = 2001 − 1900;
time_str.tm_mon = 7;
time_str.tm_mday = 4;
time_str.tm_hour = 0;
time_str.tm_min = 0;
time_str.tm_sec = 1;
time_str.tm_isdst = 1;
mktime(&time_str);
/* After calling this function,
time_str.tm_wday contains the day of
the week for July 4, 2001 */
printf (”result is %s\n”, wday[time_str.tm_wday]);
Содержание TMS320C2x
Страница 8: ...viii...
Страница 69: ...2 47 C Compiler Description...
Страница 159: ...6 36...
Страница 226: ...8 6...
Страница 250: ...Index Index 14 Z z shell option 2 2 2 4 2 14 overriding with c option 4 5 overriding with n option 2 13...