[PATCH] git-svn fix for systems without strftime %z

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



%z isn't available on all platforms in the date formatting
routines.  Detect when %z is ignored and insert the
the proper value if necessary.

Signed-off-by: Ben Walton <bwalton@xxxxxxxxxxxxxxxxxx>
---
 git-svn.perl |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index cbc5211..66f49b4 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -4615,6 +4615,7 @@ package Git::SVN::Log;
 use strict;
 use warnings;
 use POSIX qw/strftime/;
+use Time::Local;
 use constant commit_log_separator => ('-' x 72) . "\n";
 use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline
             %rusers $show_commit $incremental/;
@@ -4721,7 +4722,18 @@ sub run_pager {
 }
 
 sub format_svn_date {
-	return strftime("%Y-%m-%d %H:%M:%S %z (%a, %d %b %Y)", localtime(shift));
+	my $timestr = strftime("%Y-%m-%d %H:%M:%S %z (%a, %d %b %Y)", localtime(shift));
+
+	# for systems without %z (solaris 8, 9, etc)
+	if ($timestr =~ /%z/) {
+		my $lt = time;
+		my $gm = timelocal(gmtime($lt));
+		my $sign = qw( + + - )[ $lt <=> $gm ];
+		my $gmoff = sprintf("%s%02d%02d", $sign, (gmtime(abs($lt - $gm)))[2,1]);
+		$timestr =~ s/%z/$gmoff/;
+	}
+
+	return $timestr;
 }
 
 sub parse_git_date {
-- 
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux