Skip to content

Commit

Permalink
date.c: fix printout of timezone offsets that aren't exact hours
Browse files Browse the repository at this point in the history
We'd get the sign wrong for the minutes part of a negative offset.
  • Loading branch information
Linus Torvalds committed Apr 30, 2005
1 parent 92e2311 commit 7f26664
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions date.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7f26664

Please sign in to comment.