#include #include #include #include static void printtime (long long int t, struct tm tm) { char buf[1000]; static int n; strftime (buf, sizeof buf, "%Y-%m-%d %H:%M:%S %z (%Z)", &tm); printf ("%d. %10lld = %s %s\n", ++n, t, buf, tm.tm_isdst < 0 ? "unknown" : tm.tm_isdst ? "daylight" : "standard"); } int main (void) { setenv ("TZ", "Asia/Tehran", 1); time_t t[4] = { 283981500, 283983300, 1640982600, 1656617400 }; struct tm tm[4]; int i; for (i = 0; i < 4; i++) { tm[i] = *localtime (&t[i]); printtime (t[i], tm[i]); } for (i = 0; i < 4; i++) tm[i] = *localtime (&t[i]); for (i = 0; i < 4; i++) printtime (t[i], tm[i]); return 0; }