File fix-time-local.patch of Package perl-Email-Date-Format

Author: Bernhard M. Wiedemann <bwiedemann suse de>
Date: 2018-02-23

https://rt.cpan.org/Public/Bug/Display.html?id=124530 

Index: Email-Date-Format-1.005/lib/Email/Date/Format.pm
===================================================================
--- Email-Date-Format-1.005.orig/lib/Email/Date/Format.pm
+++ Email-Date-Format-1.005/lib/Email/Date/Format.pm
@@ -54,8 +54,12 @@ use Time::Local ();
 sub _tz_diff {
   my ($time) = @_;
 
-  my $diff  =   Time::Local::timegm(localtime $time)
-              - Time::Local::timegm(gmtime    $time);
+  my @localtime = localtime $time;
+  my @gmtime    = gmtime    $time;
+  $localtime[5] += 1900;
+  $gmtime[5]    += 1900;
+  my $diff  =   Time::Local::timegm(@localtime)
+              - Time::Local::timegm(@gmtime);
 
   my $direc = $diff < 0 ? '-' : '+';
   $diff  = abs $diff;
Index: Email-Date-Format-1.005/t/basic.t
===================================================================
--- Email-Date-Format-1.005.orig/t/basic.t
+++ Email-Date-Format-1.005/t/basic.t
@@ -1,4 +1,4 @@
-use Test::More tests => 3;
+use Test::More tests => 7;
 use strict;
 $^W = 1;
 
@@ -12,7 +12,10 @@ is(
 
 my $birthday = 1153432704; # no, really!
 
-my $tz = sprintf "%s%02u%02u", Email::Date::Format::_tz_diff(1153432704);
+sub tz($) { sprintf "%s%02u%02u", Email::Date::Format::_tz_diff(shift) }
+
+local $ENV{TZ} = "UTC+4";
+my $tz = tz(1153432704);
 
 SKIP: {
     skip "test only useful in US/Eastern, -0400, not $tz", 1 if $tz ne '-0400';
@@ -29,3 +32,12 @@ is(
   'Thu, 20 Jul 2006 21:58:24 +0000',
   "rjbs's birthday date format properly in GMT",
 );
+
+my $badyear = 1900 + ((gmtime)[5] - 49) % 100;
+my $badt = Time::Local::timegm(0, 0, 0, 1, 0, $badyear);
+$ENV{TZ} = "UTC-11";
+is(tz($badt - 60), "+1100", "positive timezone before year rollover");
+is(tz($badt + 60), "+1100", "positive timezone after year rollover");
+$ENV{TZ} = "UTC+9";
+is(tz($badt - 60), "-0900", "negative timezone before year rollover");
+is(tz($badt + 60), "-0900", "negative timezone after year rollover");
openSUSE Build Service is sponsored by