#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main(void)
{
	time_t time1;
	struct tm *ptm;
	char Str2[128];
	const char *tz = NULL;
	char tz_copy[128]; 
	
	tz = getenv("TZ");
	tz_copy[0] = 0;
	if (tz)
		strncpy_s(tz_copy, sizeof(tz_copy), tz, _TRUNCATE);
	printf("%s\n", tz_copy);
	
	_putenv_s("TZ", "JST-9");
	_tzset();
	
	time1 = time(NULL);
	ptm = localtime(&time1);
	printf("%02d:%02d:%02d\n", ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
	
	strftime(Str2, sizeof(Str2), "%H:%M:%S", ptm);
	printf("%s\n", Str2);
	
	_putenv_s("TZ", tz_copy);
	_tzset();
}
