#include #include #include void test10() { time_t t = 0; struct tm tm = {0}; char buf[64]; tm.tm_year = 2011 - 1900; tm.tm_mon = 12 - 1; tm.tm_mday = 31; // <-- here is the change tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; tm.tm_isdst = 1; strftime(buf, sizeof buf, "%F %T %Z", &tm); printf("before: %s %ld\n", buf, t); t = mktime(&tm); strftime(buf, sizeof buf, "%F %T %Z", &tm); printf("after1: %s %ld\n", buf, t); tm.tm_mday -= 1; t = mktime(&tm); strftime(buf, sizeof buf, "%F %T %Z", &tm); printf("after2: %s %ld\n", buf, t); tm.tm_mday += 1; t = mktime(&tm); strftime(buf, sizeof buf, "%F %T %Z", &tm); printf("after3: %s %ld\n", buf, t); } int main(int argc, char *argv[]) { test10(); return 0; }