#
# spec file for package date
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%global somajor 3
%global libname %{_lib}date%{somajor}
%define develname %{_lib}date-devel
# Howard Hinnant recommends using it "live at head", i.e. the latest git master.
%define opensuse_rel 3
%define opensuse_subrel 9
%define subrel 3
%define snap 20240514
Name:           date
Version:        3.0.1
Release:        %{opensuse_rel}.git%{snap}.%{opensuse_subrel}%{?subrel:.%subrel}%{?dist}
Summary:        Date and time library based on the C++11/14/17 chrono header
License:        MIT
Group:          Development/Libraries/C and C++
URL:            https://github.com/HowardHinnant/date
Source:         %{url}/releases/download/%{version}/date-%{version}.tar.gz
# The patch comes from https://github.com/HowardHinnant/date/compare/v3.0.1...master.diff
# Mainly to fix the compilation problems in C++ 17+ compilers.
Patch0:         date-%{snap}.diff
# Debian patch to eliminate use of non-portable PATH_MAX.
Patch1:         date-realpath-no-PATH_MAX.diff
BuildRequires:  cmake
BuildRequires:  gcc-c++


%description
A date and time library based on the C++11/14/17 chrono header.

%package  -n    %{libname}
Summary:        Development files for Howard Hinnant's date library
Group:          Development/Libraries/C and C++
# Old SuSE name
Obsoletes:      hhdate-devel <= 3.0.1

%description    -n %{libname}
A date and time library based on the C++11/14/17 chrono header.

%package      -n  %{develname}
Summary:        Development files for Howard Hinnant's date library
Group:          Development/Libraries/C and C++
Requires:       %{libname} = %{version}
Conflicts:      %{name} <= %{version}
# Old SuSE name
Obsoletes:      libdate-tz3 <= 3.0.1

%description   -n %{develname}
A date and time library based on the C++11/14/17 chrono header.

%prep
%autosetup -p1

%build
%cmake -DBUILD_TZ_LIB=ON -DUSE_SYSTEM_TZ_DB=ON
%cmake_build

%install
%cmake_install

%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig

%files -n %{libname}
%{_libdir}/libdate-tz.so.%{somajor}*
%license LICENSE.txt

%files -n %{develname}
%license LICENSE.txt
%{_includedir}/date/
%{_libdir}/cmake/date/
%{_libdir}/libdate-tz.so

%changelog
* Mon Jul  8 2024 Keith Bowes <zooplah@gmail.com>
- Institute a live-at-head scheme, as recommended by the author
* Thu Jul  4 2024 Keith Bowes <zooplah@gmail.com>
- Rename library from hhdate to date
- Use more Mageia-like package names
* Mon Jan  9 2023 Filippo Bonazzi <filippo.bonazzi@suse.com>
- Use local TZ database (https://bugzilla.opensuse.org/show_bug.cgi?id=1206951)
- Remove now unnecessary libcurl build dependency
* Wed Dec  7 2022 Filippo Bonazzi <filippo.bonazzi@suse.com>
- Fix file conflicts with devel package
* Tue Dec  6 2022 Soc Virnyl Estela <socvirnyl.estela@gmail.com>
- Clean up specfile: use `devel` instead of `-n hhdate-devel`
- Improve description. It's based on the chrono header
- Use %%cmake_install
- Remove rpmlint errors:
  * Package is a library and does not include an executable
  * Create a libname package
  * add postun / post ldconfig declaration
- Add license also in the libname
* Thu Dec  1 2022 Filippo Bonazzi <filippo.bonazzi@suse.com>
- Clean up spec file: redundant Provides in devel package
* Thu Dec  1 2022 Filippo Bonazzi <filippo.bonazzi@suse.com>
- Package version 3.0.1