17.05.2015 Views

TMS34010 C Compiler - Al Kossow's Bitsavers

TMS34010 C Compiler - Al Kossow's Bitsavers

TMS34010 C Compiler - Al Kossow's Bitsavers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

mktime<br />

Convert to Calendar Time<br />

Syntax<br />

Defined in<br />

Description<br />

Example<br />

#include<br />

<br />

time_t *mktime{timeptr)<br />

struct tm *timeptr;<br />

mktime.c in rts.src<br />

The mktime function converts a broken-down time, expressed as local time,<br />

into proper calendar time. The timeptr argument points to a structure that<br />

holds the broken-down time.<br />

The function ignores the original values of tm.....wday and tm.....yday, and<br />

does not restrict the other values in the structure. After successful completion,<br />

tm.....wday and tm.....yday are set appropriately, and the other components<br />

in the structure have values within the restricted ranges. The final<br />

value of tm-mday is not sent until tm.....mon and tm.....year are determined.<br />

The return value is encoded as a value of type time-to If the calendar time<br />

cannot be represented, the function returns the value -1.<br />

This example determines the day of the week that July 4, 2001, falls on.<br />

#include <br />

static const char *const wday[] = (<br />

"Sunday", "Monday", "Tuesday", "Wednesday",<br />

"Thursday", "Friday", "Saturday" };<br />

struct tm time-str;<br />

time-str.tm.....year<br />

time_str.tm-mon<br />

time_str.tm-mday<br />

time-str.tm.....hour<br />

time_str.tm-min<br />

time-str.tm.....sec<br />

time-str.tm.....isdst<br />

mktime(&time-str) ;<br />

2001 - 1900;<br />

7 ;<br />

4 ;<br />

0;<br />

0;<br />

1;<br />

1;<br />

printf ("result is %s\n", wday[time-str.tm.....wday])i<br />

/* After calling this function, time-str.tm.....wday<br />

contains the day of the week for July 4, 2001 */<br />

For more information about the functions and types that the<br />

header declares, see Section 6.1 .10 on page 6 -7.<br />

time. h<br />

6-56

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!