Created
December 4, 2019 17:03
-
-
Save Restoration/572f2ededbb8c2ae26a80ae09bbdb5c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct tm { | |
| int tm_sec; /* 秒 (0-60) */ | |
| int tm_min; /* 分 (0-59) */ | |
| int tm_hour; /* 時間 (0-23) */ | |
| int tm_mday; /* 月内の日付 (1-31) */ | |
| int tm_mon; /* 月 (0-11) */ | |
| int tm_year; /* 年 - 1900 */ | |
| int tm_wday; /* 曜日 (0-6, 日曜 = 0) */ | |
| int tm_yday; /* 年内通算日 (0-365, 1 月 1 日 = 0) */ | |
| int tm_isdst; /* 夏時間 */ | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <time.h> | |
| int main(){ | |
| struct tm tm; | |
| const char *dayofweek[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; | |
| time_t t = time(NULL); | |
| localtime_r(&t, &tm); | |
| printf("%04d/%02d/%02d %s %02d:%02d:%02d\n", | |
| tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, | |
| dayofweek[tm.tm_wday], tm.tm_hour, tm.tm_min, tm.tm_sec | |
| ); | |
| return 0; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment