| TM(3) | C LIBRARY FUNCTIONS | TM(3) |
|---|
time_t values are the number of seconds since the epoch, Jan 1 00:00:00 GMT 1970, with leap seconds omitted.
The global variable int tm_info.flags contains flags that allow all programs using the library to be controlled in a consistent manner. tm_info.flags is initialized by the tminit() routine described below, and may be explicitly reset after tminit() is called. The flags are:
The routines are:
format
is in the style of
The library routines use a table of date strings pointed to by char** tm_info.format. The indices in tm_info.format are fixed by category. tm_info.format may be changed to point to other tables according to local language and date conventions. The contents by index (showing the USA English values) are:
Low level support functions and data are described in <tm.h>.
#include <tm.h>
main() {
int i;
time_t t;
char buf[128];
struct {
char* date;
char* format;
} x[] = {
"now", "%i",
"2 months ago", "%C",
"this Wednesday noon", "%x %I:%M %p",
"last December 25", "%A",
0, 0
};
for (i = 0; x[i].date; i++) {
t = tmdate(x[i].date, (char*)0, (time_t*)0);
(void)tmform(buf, x[i].format, &t);
puts(buf);
}
}
Fri Sep 30 12:10:14 USA EDT 1988 Fri Jul 1 00:00:00 EDT 1988 10/05/88 12:00 PM Friday
| November 07, 2006 |