diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 682970a..93b5d8b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,41 +1,41 @@ -name: CI -on: - push: - branches: - - master - pull_request: -defaults: - run: - shell: bash -jobs: - test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - version: - - '1.6' - os: - - ubuntu-latest - - macOS-latest - - windows-latest - arch: - - x64 - steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 - with: - version: ${{ matrix.version }} - arch: ${{ matrix.arch }} - - uses: julia-actions/julia-buildpkg@latest - - uses: julia-actions/julia-runtest@latest - env: - RASTERDATASOURCES_PATH: "." - - if: startsWith(matrix.os,'ubuntu') - uses: julia-actions/julia-processcoverage@v1 - - if: startsWith(matrix.os,'ubuntu') - uses: codecov/codecov-action@v1 - with: - file: lcov.info - fail_ci_if_error: true +name: CI +on: + push: + branches: + - master + pull_request: +defaults: + run: + shell: bash +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + version: + - '1.6' + os: + - ubuntu-latest + - macOS-latest + - windows-latest + arch: + - x64 + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@v1 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/julia-buildpkg@latest + - uses: julia-actions/julia-runtest@latest + env: + RASTERDATASOURCES_PATH: "." + - if: startsWith(matrix.os,'ubuntu') + uses: julia-actions/julia-processcoverage@v1 + - if: startsWith(matrix.os,'ubuntu') + uses: codecov/codecov-action@v1 + with: + file: lcov.info + fail_ci_if_error: false diff --git a/src/shared.jl b/src/shared.jl index 70c4825..450ca0b 100644 --- a/src/shared.jl +++ b/src/shared.jl @@ -42,7 +42,7 @@ function _format(T::Type{<:RasterDataSource}, date::TimeType) # find which bin it is in r = range(daterange...; step = datestep) - idx = searchsortedfirst(r, date) + idx = searchsortedfirst(r, date, lt = <=) # from here on just use integer math startyear = Dates.year(first(daterange)) diff --git a/test/worldclim-future.jl b/test/worldclim-future.jl index 7394296..dddfc7c 100644 --- a/test/worldclim-future.jl +++ b/test/worldclim-future.jl @@ -47,3 +47,11 @@ end @test isfile(date_path) end + + +@testset "WorldClim dates" begin + bioclim_name = "wc2.1_10m_bioc_MRI-ESM2-0_ssp126_2041-2060.tif" + @test rastername(WorldClim{Future{BioClim,CMIP6,MRI_ESM2_0,SSP126}}, 5; date=Date(2041), res = "10m") == + rastername(WorldClim{Future{BioClim,CMIP6,MRI_ESM2_0,SSP126}}, 5; date=Date(2060), res = "10m") == + bioclim_name +end \ No newline at end of file