2022-06-27 12:34:13 +00:00
|
|
|
#include <stdio.h>
|
2023-02-15 19:02:09 +00:00
|
|
|
#include <time.h>
|
|
|
|
static const char *const wday[] = {
|
|
|
|
"Sunday", "Monday", "Tuesday", "Wednesday",
|
|
|
|
"Thursday", "Friday", "Saturday", "-unknown-"
|
|
|
|
};
|
2022-06-27 12:34:13 +00:00
|
|
|
|
|
|
|
int main() {
|
2023-02-15 19:02:09 +00:00
|
|
|
// July 4, 2001: Wednesday
|
|
|
|
struct tm time_str;
|
|
|
|
time_str.tm_year = 2001 - 1900;
|
|
|
|
time_str.tm_mon = 7 - 1;
|
|
|
|
time_str.tm_mday = 4;
|
|
|
|
time_str.tm_hour = 0;
|
|
|
|
time_str.tm_min = 0;
|
|
|
|
time_str.tm_sec = 1;
|
|
|
|
time_str.tm_isdst = -1;
|
|
|
|
time_t timestamp;
|
|
|
|
if((timestamp = mktime(&time_str)) == (time_t)(-1)) {
|
|
|
|
time_str.tm_wday = 7;
|
|
|
|
}
|
|
|
|
char const *day_of_week = wday[time_str.tm_wday];
|
|
|
|
struct tm *gmt = gmtime(×tamp);
|
|
|
|
struct tm *local = localtime(×tamp);
|
2022-06-27 12:34:13 +00:00
|
|
|
return 0;
|
2023-02-15 19:02:09 +00:00
|
|
|
}
|