@matheusbsbs / matheus-bagliano / commits / cfea8e077b
Fork 0

blame and annotate: show localtime with timezone.

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>

Junio C Hamano committed Mar 5, 2006 at 14:48 UTC cfea8e077b9a8956080688ab40e9efd812c2a0c5
2 files changed +20 -5
blame.c
+13 -4
@@ -550,13 +550,22 @@ static void get_commit_info(struct commit* commit, struct commit_info* ret)
550 *tmp = 0;
551 }
552
553 -char* format_time(unsigned long time, const char* tz)
553 +static const char* format_time(unsigned long time, const char* tz_str)
554 {
555 static char time_buf[128];
556 time_t t = time;
557 -
558 - strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", gmtime(&t));
559 - strcat(time_buf, tz);
557 + int minutes, tz;
558 + struct tm *tm;
559 +
560 + tz = atoi(tz_str);
561 + minutes = tz < 0 ? -tz : tz;
562 + minutes = (minutes / 100)*60 + (minutes % 100);
563 + minutes = tz < 0 ? -minutes : minutes;
564 + t = time + minutes * 60;
565 + tm = gmtime(&t);
566 +
567 + strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S ", tm);
568 + strcat(time_buf, tz_str);
569 return time_buf;
570 }
571
git-annotate.perl
+7 -1
@@ -418,7 +418,13 @@ sub format_date {
418 return $_[0];
419 }
420 my ($timestamp, $timezone) = split(' ', $_[0]);
421 - return strftime("%Y-%m-%d %H:%M:%S " . $timezone, gmtime($timestamp));
421 + my $minutes = abs($timezone);
422 + $minutes = int($minutes / 100) * 60 + ($minutes % 100);
423 + if ($timezone < 0) {
424 + $minutes = -$minutes;
425 + }
426 + my $t = $timestamp + $minutes * 60;
427 + return strftime("%Y-%m-%d %H:%M:%S " . $timezone, gmtime($t));
428 }
429
430 # Copied from git-send-email.perl - We need a Git.pm module..