{"thread":{"id":"17994","subject":"[PATCH] git-svn fix to avoid using strftime %z","startedAt":"2009-02-24T19:44:49Z","lastAt":"2009-02-24T21:46:20Z","messageCount":2,"participants":["Ben Walton","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"106096","messageId":"1235504689-17420-1-git-send-email-bwalton@artsci.utoronto.ca","threadId":"17994","inReplyTo":null,"subject":"[PATCH] git-svn fix to avoid using strftime %z","fromName":"Ben Walton","fromEmail":"bwalton@artsci.utoronto.ca","sentAt":"2009-02-24T19:44:49Z","receivedAt":"2009-02-24T19:44:49Z","isPatch":true,"sender":{"key":"bdwalton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/396061?v=4"},"body":"%z isn't available on all platforms in the date formatting\nroutines.  Provide a workalike capability that should be\nmore portable.\n\nSigned-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n---\nThis is the reworked version that was requested.  It drops %z completely\nfrom the strftime call in favour of the hand rolled version.  All tests\nstill pass on Linux and Solaris.\n\n git-svn.perl |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex cbc5211..24180eb 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -4615,6 +4615,7 @@ package Git::SVN::Log;\n use strict;\n use warnings;\n use POSIX qw/strftime/;\n+use Time::Local;\n use constant commit_log_separator => ('-' x 72) . \"\\n\";\n use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline\n             %rusers $show_commit $incremental/;\n@@ -4721,7 +4722,12 @@ sub run_pager {\n }\n \n sub format_svn_date {\n-\treturn strftime(\"%Y-%m-%d %H:%M:%S %z (%a, %d %b %Y)\", localtime(shift));\n+\t# some systmes don't handle or mishandle %z, so be creative.\n+\tmy $t = shift;\n+\tmy $gm = timelocal(gmtime($t));\n+\tmy $sign = qw( + + - )[ $t <=> $gm ];\n+\tmy $gmoff = sprintf(\"%s%02d%02d\", $sign, (gmtime(abs($t - $gm)))[2,1]);\n+\treturn strftime(\"%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)\", localtime($t));\n }\n \n sub parse_git_date {\n-- \n1.6.0.4\n"},{"id":"106111","messageId":"20090224214620.GA27411@dcvr.yhbt.net","threadId":"17994","inReplyTo":"1235504689-17420-1-git-send-email-bwalton@artsci.utoronto.ca","subject":"Re: [PATCH] git-svn fix to avoid using strftime %z","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-02-24T21:46:20Z","receivedAt":"2009-02-24T21:46:20Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Ben Walton <bwalton@artsci.utoronto.ca> wrote:\n> %z isn't available on all platforms in the date formatting\n> routines.  Provide a workalike capability that should be\n> more portable.\n> \n> Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>\n\nThanks Ben, acked and pushed out to git://git.bogomips.org/git-svn\n\n> ---\n> This is the reworked version that was requested.  It drops %z completely\n> from the strftime call in favour of the hand rolled version.  All tests\n> still pass on Linux and Solaris.\n> \n>  git-svn.perl |    8 +++++++-\n>  1 files changed, 7 insertions(+), 1 deletions(-)\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index cbc5211..24180eb 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -4615,6 +4615,7 @@ package Git::SVN::Log;\n>  use strict;\n>  use warnings;\n>  use POSIX qw/strftime/;\n> +use Time::Local;\n>  use constant commit_log_separator => ('-' x 72) . \"\\n\";\n>  use vars qw/$TZ $limit $color $pager $non_recursive $verbose $oneline\n>              %rusers $show_commit $incremental/;\n> @@ -4721,7 +4722,12 @@ sub run_pager {\n>  }\n>  \n>  sub format_svn_date {\n> -\treturn strftime(\"%Y-%m-%d %H:%M:%S %z (%a, %d %b %Y)\", localtime(shift));\n> +\t# some systmes don't handle or mishandle %z, so be creative.\n> +\tmy $t = shift;\n> +\tmy $gm = timelocal(gmtime($t));\n> +\tmy $sign = qw( + + - )[ $t <=> $gm ];\n> +\tmy $gmoff = sprintf(\"%s%02d%02d\", $sign, (gmtime(abs($t - $gm)))[2,1]);\n> +\treturn strftime(\"%Y-%m-%d %H:%M:%S $gmoff (%a, %d %b %Y)\", localtime($t));\n>  }\n>  \n>  sub parse_git_date {\n"}]}