[C言語]日時と時間

struct tmの構造体
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; /* 夏時間 */
};

#include <stdio.h>
#include <time.h>

int main(void){
	static char *week[] = {"日","月","火","水","木","金","土"};
	time_t now;
	struct tm
		*tm_now;

	now = time(NULL);
	tm_now = localtime(&now);
	printf("%4d年%2d月%2d日 %s曜日\n", tm_now->tm_year + 1900, tm_now->tm_mon+1, tm_now->tm_mday, week[tm_now->tm_wday]);
	printf("%2d時%2d分%2d秒\n", tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec);

	return 0;
}

$ ./main
2020年 5月31日 日曜日
4時45分40秒

あれ、9時間+する方法がわからん。

時計

int main(void){
	static char *week[] = {"日","月","火","水","木","金","土"};
	time_t now, prev;
	struct tm
		*tm_now;

	prev = -1;
	for(;;){
		now = time(NULL);
		if(prev == now)
			continue;
		prev = now;
		tm_now = localtime(&now);
		printf("%2d時%2d分%2d秒\n", tm_now->tm_hour, tm_now->tm_min, tm_now->tm_sec);
	}

	return 0;
}