# Detect the distribution in use
%global __despace head -n 1 | tr -d '[:space:]' | sed -e 's/[(].*[)]//g'
%global __lower4 cut -c 1-4 | tr '[:upper:]' '[:lower:]'
%global __distfile %([ -f /etc/SuSE-release ] && echo /etc/SuSE-release || echo /etc/redhat-release)
%global __distinit %(sed -e 's/ release .*//' -e 's/\\([A-Za-z]\\)[^ ]*/\\1/g' %{__distfile} | %{__despace} | %{__lower4})
%global __distvers %(sed -e 's/.* release \\([^. ]*\\).*/\\1/' %{__distfile} | %{__despace})
# Identify Alma, CentOS, CentOS Stream and Rocky Linux as rhel
%if "%{__distinit}" == "a" || "%{__distinit}" == "c" || "%{__distinit}" == "cl" || "%{__distinit}" == "cs" || "%{__distinit}" == "rl"
%global __distinit rhel
%endif
# Dist tag for Fedora is still "fc"
%if "%{__distinit}" == "f"
%global __distinit fc
%endif

Name:		perl-DateTime-Locale
Version:	1.45
Release:	1.0.cf.%{__distinit}%{__distvers}
Summary:	Localization support for DateTime.pm
# package itself is 'same terms as Perl'
# modules under DateTime/Locale/ are generated from data provided by the CLDR project
# tools/t/test-data contains CLDR data files under Unicode license
License:	(GPL-1.0-or-later OR Artistic-1.0-Perl) and Unicode-DFS-2015
URL:		https://metacpan.org/release/DateTime-Locale
Source0:	https://cpan.metacpan.org/modules/by-module/DateTime/DateTime-Locale-%{version}.tar.gz
BuildArch:	noarch
# Module Build
BuildRequires:	coreutils
BuildRequires:	make
BuildRequires:	perl-generators
BuildRequires:	perl-interpreter
BuildRequires:	perl(ExtUtils::MakeMaker) >= 6.76
BuildRequires:	perl(File::ShareDir::Install)
# Module Runtime
BuildRequires:	perl(Carp)
BuildRequires:	perl(Dist::CheckConflicts) >= 0.02
BuildRequires:	perl(Exporter)
BuildRequires:	perl(File::ShareDir)
BuildRequires:	perl(File::Spec)
BuildRequires:	perl(List::Util) >= 1.45
BuildRequires:	perl(namespace::autoclean) >= 0.19
BuildRequires:	perl(Params::ValidationCompiler) >= 0.13
BuildRequires:	perl(Specio::Declare)
BuildRequires:	perl(Specio::Library::String)
BuildRequires:	perl(Storable)
BuildRequires:	perl(strict)
BuildRequires:	perl(warnings)
# Test Suite
BuildRequires:	perl(base)
BuildRequires:	perl(CPAN::Meta::Check) >= 0.011
BuildRequires:	perl(CPAN::Meta::Requirements)
BuildRequires:	perl(File::Temp)
BuildRequires:	perl(IPC::System::Simple)
BuildRequires:	perl(Path::Tiny)
BuildRequires:	perl(Term::ANSIColor)
BuildRequires:	perl(Test2::Plugin::NoWarnings)
BuildRequires:	perl(Test2::Plugin::UTF8)
BuildRequires:	perl(Test2::Require::Module)
BuildRequires:	perl(Test2::V0)
BuildRequires:	perl(Test::File::ShareDir::Dist)
BuildRequires:	perl(Test::More)
BuildRequires:	perl(utf8)
# Optional Tests
BuildRequires:	perl(CPAN::Meta) >= 2.120900
BuildRequires:	perl(CPAN::Meta::Prereqs)
# Dependencies
%if 0%{?fedora} < 38 && 0%{?rhel} < 10
Requires:	perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%endif

%description
DateTime::Locale is primarily a factory for the various locale subclasses. It
also provides some functions for getting information on all the available
locales.

%prep
%setup -q -n DateTime-Locale-%{version}

%build
perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1
%{make_build}

%install
%{make_install}
%{_fixperms} -c %{buildroot}

%check
make test

%files
%license LICENSE LICENSE.cldr
%doc Changes CODE_OF_CONDUCT.md CONTRIBUTING.md README.md
%{perl_vendorlib}/auto/share/dist/DateTime-Locale/
%dir %{perl_vendorlib}/DateTime/
%{perl_vendorlib}/DateTime/Locale/
%{perl_vendorlib}/DateTime/Locale.pm
%{_mandir}/man3/DateTime::Locale.3*
%{_mandir}/man3/DateTime::Locale::*.3*

%changelog
* Tue Apr  1 2025 Paul Howarth <paul@city-fan.org> - 1.45-1.0.cf
- Update to 1.45
  - Rebuilt all locale data with the data from CLDR 47.0.0
- Use %%{make_build} and %%{make_install}
- Drop support for building with List::Util < 1.45

* Tue Oct 29 2024 Paul Howarth <paul@city-fan.org> - 1.44-1.0.cf
- Update to 1.44
  - Rebuilt all locale data with the data from CLDR 46.0.0

* Sun Jul 28 2024 Paul Howarth <paul@city-fan.org> - 1.43-1.0.cf
- Update to 1.43
  - Fixed the prefers_24_hour_time method, which was incorrectly returning
    false when the locale's time_format_short method contained a quote string
    with "h" or "K" in it, e.g. the fr-CA locale's time_format_short is
    "HH 'h' mm": the quoted 'h' caused this method to return false (GH#39)

* Fri Apr 19 2024 Paul Howarth <paul@city-fan.org> - 1.42-1.0.cf
- Update to 1.42
  - Rebuilt all locale data with the data from CLDR 45.0.0

* Sat Apr  6 2024 Paul Howarth <paul@city-fan.org> - 1.41-1.0.cf
- Update to 1.41
  - Rebuilt all locale data with the data from CLDR 44.1.0

* Tue Nov  7 2023 Paul Howarth <paul@city-fan.org> - 1.40-1.0.cf
- Update to 1.40
  - Rebuilt all locale data with the data from CLDR 44.0.1

* Mon May 29 2023 Paul Howarth <paul@city-fan.org> - 1.39-1.0.cf
- Update to 1.39
  - Fixed parsing of the 'el-polyton' locale code: this had the same issue as
    'be-tarask', which was fixed in 1.36; this is now fixed in such a way that
    similar language+variant codes will be parsed correctly in the future
    (GH#37)
- Avoid use of deprecated patch syntax

* Sun Apr 16 2023 Paul Howarth <paul@city-fan.org> - 1.38-1.0.cf
- Update to 1.38
  - Rebuilt all locale data with the data from CLDR 43.0.0

* Mon Oct 24 2022 Paul Howarth <paul@city-fan.org> - 1.37-1.0.cf
- Update to 1.37
  - Rebuilt all locale data with the data from CLDR 42.0.0

* Mon Aug 22 2022 Paul Howarth <paul@city-fan.org> - 1.36-1.0.cf
- Update to 1.36
  - Fixed misparsing of the 'be-tarask' locale code (GH#32)
    - This is a locale with just a language name and a variant
    - The locale parsing code assumed that all two-part locale codes had either
      a script or territory, not a variant; this caused the catalog to show the
      name of this locale as "Belarusian", the same as the 'be' code
- Use SPDX-format license tag

* Mon Apr 25 2022 Paul Howarth <paul@city-fan.org> - 1.35-1.0.cf
- Update to 1.35
  - The code passed to DateTime::Locale->load is now validated and untainted
    before using it to load and eval data from the filesystem (based on GH#30)

* Fri Apr  8 2022 Paul Howarth <paul@city-fan.org> - 1.34-1.0.cf
- Update to 1.34
  - Rebuilt all locale data with the data from CLDR 41.0.0

* Sun Oct 31 2021 Paul Howarth <paul@city-fan.org> - 1.33-1.0.cf
- Update to 1.33
  - Rebuilt all locale data with the data from CLDR 40.0.0; there are some
    notable data changes in CLDR 40.0.0
  - Data change: The root locale is now named "und", not "root"
  - Data change: The "en-US-POSIX" locale has been removed from CLDR; if you
    load this locale you will now get the "en-US" locale
- Fix dist tags for Alma and Rocky Linux

* Mon May  3 2021 Paul Howarth <paul@city-fan.org> - 1.32-1.0.cf
- Update to 1.32
  - Rebuilt all locale data with the data from CLDR 39.0.0
- Use %%license unconditionally

* Wed Dec 23 2020 Paul Howarth <paul@city-fan.org> - 1.31-1.0.cf
- Update to 1.31
  - The docs for each locale now show examples of its strftime patterns as well

* Wed Dec 16 2020 Paul Howarth <paul@city-fan.org> - 1.30-1.0.cf
- Update to 1.30
  - The previous release included some locale data for locales that had been
    deleted from CLDR 38.0.0

* Tue Dec 15 2020 Paul Howarth <paul@city-fan.org> - 1.29-1.0.cf
- Update to 1.29
  - Rebuilt all locale data with the data from CLDR 38.0.0 and glibc 2.32

* Sat Aug 29 2020 Paul Howarth <paul@city-fan.org> - 1.28-1.0.cf
- Update to 1.28
  - The $locale->locale_data method now returns a deep clone of the locale's
    data; this allows you to modify safely any elements of the returned hash
    without breaking the original locale (GH#26)
  - We now support loading locale data from relative directories in @INC
    (GH#25)
  - When loading locale data, we now check $! for read errors, as well as
    checking for an error eval'ing the file's contents in $@ (GH#24)

* Fri Jul  3 2020 Paul Howarth <paul@city-fan.org> - 1.26-1.0.cf
- Update to 1.26
  - Rebuilt all locale data with CLDR 37, released on 2020-04-23

* Fri Oct 11 2019 Paul Howarth <paul@city-fan.org> - 1.25-1.0.cf
- Update to 1.25
  - Rebuilt all locale data with CLDR 36, released on 2019-10-04

* Fri Mar 29 2019 Paul Howarth <paul@city-fan.org> - 1.24-1.0.cf
- Update to 1.24
  - Rebuilt all locale data with CLDR 35, released on 2019-03-27

* Thu Oct 18 2018 Paul Howarth <paul@city-fan.org> - 1.23-1.0.cf
- Update to 1.23
  - Rebuilt all locale data with CLDR 34, released on 2018-10-15

* Mon Jun 11 2018 Paul Howarth <paul@city-fan.org> - 1.22-1.0.cf
- Update to 1.22
  - Rebuilt all locale data with the glibc data from glibc 2.27
  - Added documentation for this glibc data
  - Reformatted the DateTime::Locale::FromData docs
- Switch upstream from search.cpan.org to metacpan.org

* Mon May  7 2018 Paul Howarth <paul@city-fan.org> - 1.20-1.0.cf
- Update to 1.20
  - Fix test failures on Windows (GH#23)

* Tue Apr 24 2018 Paul Howarth <paul@city-fan.org> - 1.19-1.0.cf
- Update to 1.19
  - Fix handling of a locale (nds) that does not provide a native name for its
    own locale code; this is a bug in CLDR, but since it exists we should
    handle it sanely
  - If you attempted to thaw a DateTime::Locale::FromData object in a process
    that had not loaded DateTime::Locale, this would fail (GH#18)

* Wed Apr  4 2018 Paul Howarth <paul@city-fan.org> - 1.18-1.0.cf
- Update to 1.18
  - Rebuilt all locale data with CLDR 33, released on 2018-03-26

* Mon Nov  6 2017 Paul Howarth <paul@city-fan.org> - 1.17-1.0.cf
- Update to 1.17
  - Rebuilt all locale data with CLDR 32, released on 2017-11-01
- BR: perl-generators unconditionally
- BR: perl-interpreter rather than perl
- Drop support for EOL distributions prior to F-13
  - Drop BuildRoot: and Group: tags
  - Drop explicit buildroot cleaning in %%install section
  - Drop explicit %%clean section

* Wed Mar 22 2017 Paul Howarth <paul@city-fan.org> - 1.16-1.0.cf
- Update to 1.16
  - Most data is now stored in a share dir and only loaded as needed, which
    should reduce the memory usage from just loading DateTime::Locale by about
    4MB (GH#14)
  - Rebuilt all locale data with CLDR 31, released on 2017-03-20
- Drop bundled Test::More and Test::Warnings as we can no longer support
  distributions prior to F-9 due to new Test::File::ShareDir dependency
- Update patch for old distributions without recent List::Util

* Mon Mar  6 2017 Paul Howarth <paul@city-fan.org> - 1.14-1.0.cf
- Update to 1.14
  - Fixed a regression bug where providing a locale's English name or native
    name to DateTime::Locale->load no longer worked (GH#13)
  - Codes with just a language and script code were not parsed correctly,
    leading to bugs in their data such that they did not report a script_code,
    nor did their name reflect the script, e.g. "bs-Latn" was just "Bosnian"
    instead of "Bosnian Latin"

* Mon Jan 30 2017 Paul Howarth <paul@city-fan.org> - 1.12-1.0.cf
- Update to 1.12
  - Rebuilt all locale data with CLDR 30.0.3, released on 2016-12-02

* Mon Jan  9 2017 Paul Howarth <paul@city-fan.org> - 1.11-2.0.cf
- Test::Warnings now available back to Fedora 9

* Mon Nov 14 2016 Paul Howarth <paul@city-fan.org> - 1.11-1.0.cf
- Update to 1.11
  - Switched from RT to the GitHub issue tracker

* Sat Oct 22 2016 Paul Howarth <paul@city-fan.org> - 1.10-1.0.cf
- Update to 1.10
  - Don't let warnings from other modules cause t/09version-check.t to fail
    (CPAN RT#118465)
`
* Tue Oct 11 2016 Paul Howarth <paul@city-fan.org> - 1.09-1.0.cf
- Update to 1.09
  - Rebuilt all locale data with CLDR 30, released on 2016-10-05

* Sun Sep 25 2016 Paul Howarth <paul@city-fan.org> - 1.08-1.0.cf
- Update to 1.08
  - Require namespace::autoclean 0.19+

* Sun Sep 18 2016 Paul Howarth <paul@city-fan.org> - 1.07-1.0.cf
- Update to 1.07
  - Replaced Params::Validate with Params::ValidationCompiler
  - Bump minimum required Perl to 5.8.4 from 5.8.1; this matches DateTime.pm
    itself
- Update patch for old distributions without recent List::Util

* Mon Jun 27 2016 Paul Howarth <paul@city-fan.org> - 1.05-1.0.cf
- Update to 1.05
  - Instead of using the DATA handle to get at as-yet-unloaded locale data in
    DateTime::Locale::Data, we now read the raw data into memory once, and use
    eval to turn it into Perl data structures as a particular locale is
    requested, which may fix a problem where reading from the DATA handle
    somehow returned the wrong chunk of data (or overlapped multiple locales);
    the downside is that loading DateTime::Locale now uses an additional 4MB of
    memory on my system, regardless of how many individual locales are
    instantiated (GH#3)

* Sun Jun 19 2016 Paul Howarth <paul@city-fan.org> - 1.04-1.0.cf
- Update to 1.04
  - Replaced List::MoreUtils with List::Util
- Add patch to revert to List::MoreUtils when List::Util is too old
- BR: perl-generators where available
- Simplify find command using -delete

* Sun Mar 27 2016 Paul Howarth <paul@city-fan.org> - 1.03-1.0.cf
- Update to 1.03
  - Rebuilt all locale data with CLDR 29, released on 2016-03-19

* Thu Dec 10 2015 Paul Howarth <paul@city-fan.org> - 1.02-1.0.cf
- Update to 1.02
  - Make the DateTime::Locale->load method accept a locale in any non-canonical
    casing, such as "en-us" (CPAN RT#110244)

* Sun Nov  8 2015 Paul Howarth <paul@city-fan.org> - 1.01-1.0.cf
- Update to 1.01
  Enhancements
  - This release uses the locale data from CLDR version 28; the last major
    update of the locale data used CLDR 1.7.1, released in 2009, so this is a
    big change - many things have changed in terms of locale data
  - Some locales are no longer available because they are not in the CLDR data
  - The CLDR data no longer includes default date and time format lengths; this
    is now "medium" for every locale, simply to provide some level of backwards
    compatibility
  - Loading DateTime::Locale itself is now quite a bit faster; the whole locale
    registration system has been removed entirely, except for custom locales
    (CPAN RT#78794)
  - A long-standing issue with the Austrian locale not using the Austrian name
    for January has been fixed (CPAN RT#52337)
  Backwards Incompatibilities
  - This is a big new release, and includes a number of backwards-incompatible
    changes, though most users should be unaffected by this change; if you only
    use this module via DateTime.pm, you are unlikely to notice any changes
    other than changes to the locale data
  - The old API deprecated since 0.40 has been removed (almost) entirely
  - We now refer to things as "code" in the docs and method names where we used
    to call them ids; this includes locale, language, script, territory, and
    variant codes - this is more in line with the various ISO standards and the
    CLDR packages
  - All the $locale->*_id methods (including $locale->id) are deprecated; use
    the relevant $locale->*_code method instead
  - The canonical form of the locale codes now uses dashes (-) instead of
    underscores (_); loading a locale with an underscore in the name (e.g.
    en_US) still works
  - The way that locale data is packaged has changed quite a bit; we no longer
    package each locale in its own class: instead, all locale data is in a
    single module (mostly in a __DATA__ section) and loaded into memory as
    needed, so if you have any code that checks $locale->isa, that code may
    break
  - Locales are no longer subclasses of DateTime::Locale::Base; this module is
    still included in the distribution in case someone has a custom locale that
    inherits from this module, but this module will go away in a future release
  - The "ii-*" aliases for the "he-*" locales have been removed
  - The "no-*" aliases for the "nn-*" locales have been removed
  - The value of $locale->code no longer reflects the value passed to
    DateTime::Locale->load; this only affects aliases and non-canonical forms of
    the code, e.g. if you load "en_US" then $locale->code will return "en-US"
    and if you load "C" or "POSIX" the returned code will be "en-US-POSIX"
  - All of the documentation related to creating aliases and registering custom
    locales has been removed; all of these methods still work, but I don't think
    this system got much use, so I don't want to emphasize it in the docs (but
    let me know if you are using this and want to see these docs restored)
- Bundle Test::More and Test::Warnings for use with old distributions

* Mon Sep 28 2015 Paul Howarth <paul@city-fan.org> - 0.92-1.0.cf
- Update to 0.92 (no changes)

* Mon Jun 29 2015 Paul Howarth <paul@city-fan.org> - 0.46-3.0.cf
- Perl 5.22 rebuild

* Fri May 22 2015 Paul Howarth <paul@city-fan.org> - 0.46-1.0.cf
- Update to 0.46
  - Fixed handling of C locales like "C.UTF-8"; passing these to
    DateTime::Locale->load would cause a warning followed by an exception, but
    all "C" locales should be special-cased as an alias of en-US-POSIX
    (CPAN RT#104574)
- Switch to ExtUtils::MakeMaker flow
- Classify buildreqs by usage

* Fri Sep 12 2014 Paul Howarth <paul@city-fan.org> - 0.45-22.0.cf
- Drop %%defattr, redundant since rpm 4.4
- Use %%license where possible

* Tue Jul 23 2013 Paul Howarth <paul@city-fan.org> - 0.45-21.0.cf
- Perl 5.18 rebuild

* Tue Jul  2 2013 Paul Howarth <paul@city-fan.org> - 0.45-20.0.cf
- DateTime::LocaleCatalog has been renamed to DateTime::Locale::Catalog
  and cannot be loaded, which broke the POD coverage test

* Tue Jul 10 2012 Paul Howarth <paul@city-fan.org> - 0.45-19.0.cf
- BR: perl(base), perl(Carp), perl(File::Spec), perl(lib) and perl(Storable)
- Update UTF8 patch to fix broken POD test
- Don't need to remove empty directories from the buildroot
- Drop support for old distributions prior to FC-3:
  - Don't need to define %%{perl_vendorlib}
  - Don't need to run test suite with LC_ALL=C

* Fri Aug 19 2011 Paul Howarth <paul@city-fan.org> - 0.45-18.0.cf
- Unbundled from perl-DateTime