#include /* C example */ #include #include /* for time_t, time, localtime */ int main(int argc, char **argv) { const time_t t = time(NULL); const struct tm *p; /* uninitialized and not *const */ if (t == (time_t)-1) { fprintf(stderr, "%s: time failed\n", argv[0]); return EXIT_FAILURE; } p = localtime(&t); printf( "day == %d\n", p->tm_mday); printf("month == %d\n", p->tm_mon + 1); printf( "year == %d\n", p->tm_year + 1900); return EXIT_SUCCESS; }