Skip to content

Commit

Permalink
blame and annotate: show localtime with timezone.
Browse files Browse the repository at this point in the history
Earlier they showed gmtime and timezone, which was inconsistent
with the way our commits and tags are pretty-printed.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Mar 6, 2006
1 parent a0fb95e commit cfea8e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
17 changes: 13 additions & 4 deletions blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,22 @@ static void get_commit_info(struct commit* commit, struct commit_info* ret)
*tmp = 0;
}

char* format_time(unsigned long time, const char* tz)
static const char* format_time(unsigned long time, const char* tz_str)
{
static char time_buf[128];
time_t t = time;

strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", gmtime(&t));
strcat(time_buf, tz);
int minutes, tz;
struct tm *tm;

tz = atoi(tz_str);
minutes = tz < 0 ? -tz : tz;
minutes = (minutes / 100)*60 + (minutes % 100);
minutes = tz < 0 ? -minutes : minutes;
t = time + minutes * 60;
tm = gmtime(&t);

strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", tm);
strcat(time_buf, tz_str);
return time_buf;
}

Expand Down
8 changes: 7 additions & 1 deletion git-annotate.perl
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,13 @@ sub format_date {
return $_[0];
}
my ($timestamp, $timezone) = split(' ', $_[0]);
return strftime("%Y-%m-%d %H:%M:%S " . $timezone, gmtime($timestamp));
my $minutes = abs($timezone);
$minutes = int($minutes / 100) * 60 + ($minutes % 100);
if ($timezone < 0) {
$minutes = -$minutes;
}
my $t = $timestamp + $minutes * 60;
return strftime("%Y-%m-%d %H:%M:%S " . $timezone, gmtime($t));
}

# Copied from git-send-email.perl - We need a Git.pm module..
Expand Down

0 comments on commit cfea8e0

Please sign in to comment.