Hi, I found that sometimes the localtime() won't work properly, if sp->defaulttype is not set properly. For example, given the following code: time_t epoch = 0; setenv("TZ", "UTC+00", 1); tzset(); printf("%s", ctime(&epoch)); // (a) setenv("TZ", "Asia/Taipei", 1); tzset(); printf("%s", ctime(&epoch)); // (b) setenv("TZ", "UTC+00", 1); tzset(); printf("%s", ctime(&epoch)); // (c) The expected output should be: Thu Jan 1 00:00:00 1970 Thu Jan 1 08:00:00 1970 Thu Jan 1 00:00:00 1970 However, the output is: Thu Jan 1 00:00:00 1970 Thu Jan 1 08:00:00 1970 Thu Jan 1 08:00:00 1970 This is due to the fact that sp->defaulttype is set to 1 when we are using "Asia/Taipei" as the timezone, but it is not reset after we change the timezone to "UTC+00". As the result, the old value in sp->types[sp->defaulttype] is incorrectly used. The attached patch should resolve this issue. Please have a look. Thanks. Sincerely, Logan