Browse Source

fix sign of strftime %z output with offsets <1 hour west of UTC

the sign character produced came from the sign of tm_gmtoff/3600 as an
integer division, which is zero for negative offsets smaller in
magnitude than 3600. instead of printing the hours and minutes as
separate fields, print them as a single value of the form
hours*100+minutes, which naturally has the correct sign.
master
Rich Felker 8 years ago
parent
commit
1ad8138819
  1. 5
      src/time/strftime.c

5
src/time/strftime.c

@ -181,9 +181,8 @@ const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *
*l = 0; *l = 0;
return ""; return "";
} }
*l = snprintf(*s, sizeof *s, "%+.2ld%.2d", *l = snprintf(*s, sizeof *s, "%+.4ld",
(tm->__tm_gmtoff)/3600, tm->__tm_gmtoff/3600*100 + tm->__tm_gmtoff%3600/60);
abs(tm->__tm_gmtoff%3600)/60);
return *s; return *s;
case 'Z': case 'Z':
if (tm->tm_isdst < 0) { if (tm->tm_isdst < 0) {

Loading…
Cancel
Save