summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-08-07 22:15:04 -0400
committerRich Felker <dalias@aerifal.cx>2018-08-07 22:15:04 -0400
commit1ad8138819ced49851e618c9c063aa0ffc86718c (patch)
tree1342d56489570d42c163535bd2b6791aad0111c7 /src
parent7dad9c212587267818de919dd9c5886f18f99779 (diff)
downloadmusl-1ad8138819ced49851e618c9c063aa0ffc86718c.tar.gz
musl-1ad8138819ced49851e618c9c063aa0ffc86718c.tar.bz2
musl-1ad8138819ced49851e618c9c063aa0ffc86718c.tar.xz
musl-1ad8138819ced49851e618c9c063aa0ffc86718c.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/time/strftime.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/time/strftime.c b/src/time/strftime.c
index 0a256970..d3f2add9 100644
--- a/src/time/strftime.c
+++ b/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;
return "";
}
- *l = snprintf(*s, sizeof *s, "%+.2ld%.2d",
- (tm->__tm_gmtoff)/3600,
- abs(tm->__tm_gmtoff%3600)/60);
+ *l = snprintf(*s, sizeof *s, "%+.4ld",
+ tm->__tm_gmtoff/3600*100 + tm->__tm_gmtoff%3600/60);
return *s;
case 'Z':
if (tm->tm_isdst < 0) {