From: Chris Rorvick Date: Sat, 13 Oct 2012 04:11:54 GMT Subject: [PATCH v2 1/2] git-cvsimport: use localtime for converting timestamps Message-ID: <35710ee78133792f4c79b0afeb56804d745c1de5.1350100320.git.chris@rorvick.com> In-Reply-To: cvsps formats timestamps for the local timezone in its output. Using timegm() to convert to epoch-relative only works because cvsimport overrides TZ to "UTC". Using timelocal() does not change the behavior of the script as is, but it does ensure cvsimport behaves sanely if run with another TZ value. Also, use localtime() for generating the commit timestamp instead of gmtime(). Again, this has no affect on the script as is since TZ is hard-wired to "UTC". But using localtime() would allow someone to change the value of TZ with what is likely the desired effect (i.e., timestamps are written to the Git commit with local timezone offset.) Signed-off-by: Chris Rorvick --- git-cvsimport.perl | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 8032f23..2f5da9e 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -582,7 +582,7 @@ sub pdate($) { m#(\d{2,4})/(\d\d)/(\d\d)\s(\d\d):(\d\d)(?::(\d\d))?# or die "Unparseable date: $d\n"; my $y=$1; $y-=1900 if $y>1900; - return timegm($6||0,$5,$4,$3,$2-1,$y); + return timelocal($6||0,$5,$4,$3,$2-1,$y); } sub pmode($) { @@ -844,7 +844,7 @@ sub commit { } } - my $commit_date = strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date)); + my $commit_date = strftime("%z %Y-%m-%d %H:%M:%S",localtime($date)); $ENV{GIT_AUTHOR_NAME} = $author_name; $ENV{GIT_AUTHOR_EMAIL} = $author_email; $ENV{GIT_AUTHOR_DATE} = $commit_date; -- 1.7.1