diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-30 16:18:41 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-30 16:18:41 -0700 |
commit | 7f26664f1f03571cf3bde2fb3d321b9933690638 (patch) | |
tree | 85d1354a9117f2f08292e536e5daf8a2ce996669 | |
parent | 92e2311b6c10bf1e4f3e1231d26a6e71d81c5f47 (diff) | |
download | git-7f26664f1f03571cf3bde2fb3d321b9933690638.tar.gz |
date.c: fix printout of timezone offsets that aren't exact hours
We'd get the sign wrong for the minutes part of a negative offset.
-rw-r--r-- | date.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -250,7 +250,7 @@ static int match_tz(char *date, int *offp) void parse_date(char *date, char *result, int maxlen) { struct tm tm; - int offset; + int offset, sign; time_t then; memset(&tm, 0, sizeof(tm)); @@ -293,7 +293,13 @@ void parse_date(char *date, char *result, int maxlen) then -= offset * 60; - snprintf(result, maxlen, "%lu %+03d%02d", then, offset/60, offset % 60); + sign = '+'; + if (offset < 0) { + offset = -offset; + sign = '-'; + } + + snprintf(result, maxlen, "%lu %c%02d%02d", then, sign, offset/60, offset % 60); } void datestamp(char *buf, int bufsize) |