pkgname=date
pkgver=3.0.3
pkgdesc="Date and time library based on the C++11/14/17 <chrono> header"
homepage="https://github.com/HowardHinnant/date"
license=("MIT")
_patches=("date-3.0.3_remove-failing-tests.patch")
_patche_sums=("e5a453239592d4852d05b50f1f428f6cbc3b0415a247d1e3e9aea4cef42a02d3e9f65233bb717629e2670667e73e700af72eba5374faa6f96f5e952f630d45e1")
sources=("${pkgname}-${pkgver}.tar.gz"
  "${_patches[@]}"
)
urls=("https://github.com/HowardHinnant/date/archive/refs/tags/v${pkgver}.tar.gz"
  "${_patches[@]}"
)
sha512sums=("e11d7f230ecc431d94c4b58fe7394dd57a9ec0baa9de52496578479b51bbf885566d6666882916d84d388060fa36065b3fa8dd3a8bc14f720b38d1c943f06700"
  "${_patche_sums[@]}"
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
    for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done
}

src_build() {
  local cmake_args=(
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_BUILD_TYPE=release
    -D BUILD_SHARED_LIBS=true
    -D BUILD_TZ_LIB=ON
    -D USE_SYSTEM_TZ_DB=ON
    -D ENABLE_DATE_TESTING=no
    -D COMPILE_WITH_C_LOCALE=no
  )
  cmake -B build "${cmake_args[@]}"
  cmake --build build
}

src_check() {
  cd test
  ./testit
}

src_install() {
  DESTDIR="$pkgdir" cmake --install build
}

# vim:ft=sh syn=sh et sw=2:
