Skip to content

Commit

Permalink
Fix incorrect strftime error handling in rust_localtime
Browse files Browse the repository at this point in the history
Closes #8702.
  • Loading branch information
poiru committed Sep 1, 2013
1 parent 6178501 commit 30fc2c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/rt/rust_builtin.cpp
Expand Up @@ -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);
Expand Down

5 comments on commit 30fc2c8

@bors
Copy link
Contributor

@bors bors commented on 30fc2c8 Sep 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from cmr
at poiru@30fc2c8

@bors
Copy link
Contributor

@bors bors commented on 30fc2c8 Sep 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging poiru/rust/issue-8702 = 30fc2c8 into auto

@bors
Copy link
Contributor

@bors bors commented on 30fc2c8 Sep 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poiru/rust/issue-8702 = 30fc2c8 merged ok, testing candidate = c70486f

@bors
Copy link
Contributor

@bors bors commented on 30fc2c8 Sep 1, 2013

@bors
Copy link
Contributor

@bors bors commented on 30fc2c8 Sep 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = c70486f

Please sign in to comment.