Fix incorrect strftime error handling in rust_localtime

Closes #8702.
This commit is contained in:
Birunthan Mohanathas 2013-09-01 14:57:29 +03:00
parent 617850131b
commit 30fc2c8df2

View File

@ -321,13 +321,16 @@ rust_localtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
time_t s = sec;
LOCALTIME(&s, &tm);
const char* zone = NULL;
#if defined(__WIN32__)
int32_t gmtoff = -timezone;
char zone[64];
strftime(zone, sizeof(zone), "%Z", &tm);
char buffer[64];
if (strftime(buffer, sizeof(buffer), "%Z", &tm) > 0) {
zone = buffer;
}
#else
int32_t gmtoff = tm.tm_gmtoff;
const char *zone = tm.tm_zone;
zone = tm.tm_zone;
#endif
tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);