#include        <string.h>
#include        <sys/types.h>
#include        <stdlib.h>
#include        <time.h>
#include        <limits.h>

extern int tz;
int set_tz(tzval) char *tzval;  {
	char    *tz;
        static char     buf[100];
	(void) strcpy(buf, "TZ=");
	(void) strcat(buf, tzval);

	putenv(buf);
        tz = getenv("TZ");
        if (tz == NULL || strcmp(tz, tzval) != 0)
        {
		printf("Error setting TZ!");
	}
}
			

int main() {
	
	printf("timezone at start of program:%ld \n",timezone);
	printf("running ctime with \"586185855L\" as time \n");
	time_t mytime = 586185855L;
	char * c = ctime(&mytime);
	printf("timezone:%ld\n",timezone);
	
	set_tz("JKL3:10");
	ctime(&mytime);
	printf("timezone with TZ=JKL3:10 :  %ld  \n",timezone);
	
	set_tz("PNM4:40");
	ctime(&mytime);
	printf("timezone with TZ=PNM4:40 :  %ld  \n",timezone);

	set_tz("JKL3:10PNM4:40");
	ctime(&mytime);
	printf("timezone with TZ=JKL3:10PNM4:40 (!!! expected 11400 !!!):  %ld\n",timezone);
	
}
