Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-03-07 01:54:08 +0300
committerJunio C Hamano <gitster@pobox.com>2018-03-07 01:54:08 +0300
commit179e1f53b8a8ce4ea756e644fc1da0006d8f0c25 (patch)
tree997bfbc5ad35898edcdc42464c2245f992678e7c
parent6c3e6f6fcbdd12c70a849e4e1be57d82edb8f14f (diff)
parenta40e06ee336d608cfe0928d91d2b44112d8fd1e2 (diff)
Merge branch 'bw/perl-timegm-timelocal-fix'
Y2k20 fix ;-) for our perl scripts. * bw/perl-timegm-timelocal-fix: perl: call timegm and timelocal with 4-digit year
-rwxr-xr-xcontrib/examples/git-svnimport.perl2
-rwxr-xr-xgit-cvsimport.perl4
-rw-r--r--perl/Git.pm4
-rw-r--r--perl/Git/SVN.pm2
4 files changed, 8 insertions, 4 deletions
diff --git a/contrib/examples/git-svnimport.perl b/contrib/examples/git-svnimport.perl
index c414f0d9c7..75a43e23b6 100755
--- a/contrib/examples/git-svnimport.perl
+++ b/contrib/examples/git-svnimport.perl
@@ -238,7 +238,7 @@ sub pdate($) {
my($d) = @_;
$d =~ m#(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)#
or die "Unparseable date: $d\n";
- my $y=$1; $y-=1900 if $y>1900;
+ my $y=$1; $y+=1900 if $y<1000;
return timegm($6||0,$5,$4,$3,$2-1,$y);
}
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 2d8df83172..b31613cb8a 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -601,7 +601,9 @@ sub pdate($) {
my ($d) = @_;
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;
+ my $y=$1;
+ $y+=100 if $y<70;
+ $y+=1900 if $y<1000;
return timegm($6||0,$5,$4,$3,$2-1,$y);
}
diff --git a/perl/Git.pm b/perl/Git.pm
index 9d60d7948b..a7440a1f09 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -534,7 +534,9 @@ If TIME is not supplied, the current local time is used.
sub get_tz_offset {
# some systems don't handle or mishandle %z, so be creative.
my $t = shift || time;
- my $gm = timegm(localtime($t));
+ my @t = localtime($t);
+ $t[5] += 1900;
+ my $gm = timegm(@t);
my $sign = qw( + + - )[ $gm <=> $t ];
return sprintf("%s%02d%02d", $sign, (gmtime(abs($t - $gm)))[2,1]);
}
diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index bc4eed3d75..991a5885e9 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -1405,7 +1405,7 @@ sub parse_svn_date {
$ENV{TZ} = 'UTC';
my $epoch_in_UTC =
- Time::Local::timelocal($S, $M, $H, $d, $m - 1, $Y - 1900);
+ Time::Local::timelocal($S, $M, $H, $d, $m - 1, $Y);
# Determine our local timezone (including DST) at the
# time of $epoch_in_UTC. $Git::SVN::Log::TZ stored the