[libdatetime-format-human-duration-perl] 06/08: Add patch DateTime-Locale-compatibility.diff

Nick Morrott nickm-guest at moszumanska.debian.org
Thu Mar 10 02:18:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

nickm-guest pushed a commit to branch master
in repository libdatetime-format-human-duration-perl.

commit 530b66f77f4b768ceaba22ee62c46daff1b135d9
Author: Nick Morrott <knowledgejunkie at gmail.com>
Date:   Thu Mar 10 01:36:10 2016 +0000

    Add patch DateTime-Locale-compatibility.diff
    
    - patch adds compatibility for newer versions of DateTime::Locale
    - https://github.com/mstratman/DateTime-Format-Human-Duration/pull/7/commits
---
 debian/patches/DateTime-Locale-compatibility.diff | 55 +++++++++++++++++++++++
 debian/patches/series                             |  1 +
 2 files changed, 56 insertions(+)

diff --git a/debian/patches/DateTime-Locale-compatibility.diff b/debian/patches/DateTime-Locale-compatibility.diff
new file mode 100644
index 0000000..ed91423
--- /dev/null
+++ b/debian/patches/DateTime-Locale-compatibility.diff
@@ -0,0 +1,55 @@
+Description: Add compatibility for newer versions of DateTime::Locale (RT #108601)
+Bug: https://github.com/mstratman/DateTime-Format-Human-Duration/pull/7
+Author: Slaven Rezic <slaven at rezic.de>
+Last-Update: 2016-03-10
+
+--- a/lib/DateTime/Format/Human/Duration.pm
++++ b/lib/DateTime/Format/Human/Duration.pm
+@@ -17,7 +17,11 @@
+     my $dur = $dt - $dtb;
+ 
+     if (!exists $args{'locale'}) {
+-        $args{'locale'} = $dt->{'locale'}{'id'};
++	if (UNIVERSAL::can($dt->{'locale'}, 'code')) {
++	    $args{'locale'} = $dt->{'locale'}->code; # DateTime::Locale v1
++	} else {
++	    $args{'locale'} = $dt->{'locale'}->id;   # DateTime::Locale v0
++	}
+     }
+     
+     return $span->format_duration($dur, %args);    
+--- a/lib/DateTime/Format/Human/Duration/Locale.pm
++++ b/lib/DateTime/Format/Human/Duration/Locale.pm
+@@ -46,15 +46,24 @@
+     return '' if !$args_hr->{'get_locale_from'};
+ 
+     if (ref $args_hr->{'get_locale_from'}) {
+-        my $ns = ref($args_hr->{'get_locale_from'});
++	my $locale_obj;
++	if (UNIVERSAL::can($args_hr->{'get_locale_from'}, 'locale')) {
++	    $locale_obj = $args_hr->{'get_locale_from'}->locale;
++	}
++	else {
++	    $locale_obj = $args_hr->{'get_locale_from'};
++	}
+ 
+-        if (exists $args_hr->{'get_locale_from'}{'locale'}) {
+-            $ns = exists $args_hr->{'get_locale_from'}{'locale'}{'id'} ? $args_hr->{'get_locale_from'}{'locale'}{'id'} : ref($args_hr->{'get_locale_from'}{'locale'});
+-        }
+-        elsif ($ns =~ m{^DateTime::Locale::} && exists $args_hr->{'get_locale_from'}{'id'}) {
+-            $ns = $args_hr->{'get_locale_from'}{'id'};
+-        }
+-        ($args_hr->{'get_locale_from'}) = reverse split /::/, $ns;
++	if (UNIVERSAL::can($locale_obj, 'code')) {
++	    $args_hr->{'get_locale_from'} = $locale_obj->code; # DateTime::Locale v1
++	}
++	elsif (UNIVERSAL::can($locale_obj, 'id')) {
++	    $args_hr->{'get_locale_from'} = $locale_obj->id;   # DateTime::Locale v0
++	}
++	else {
++	    my $ns = ref($args_hr->{'get_locale_from'});
++	    ($args_hr->{'get_locale_from'}) = reverse split /::/, $ns;
++	}
+     }
+     
+     my ($short) = split(/[-_]+/,$args_hr->{'get_locale_from'});
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..dcc8378
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+DateTime-Locale-compatibility.diff

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdatetime-format-human-duration-perl.git



More information about the Pkg-perl-cvs-commits mailing list