Skip to content

check_is_recent gives wrong result for epiweeks #320

@brookslogan

Description

@brookslogan
library(epidatr)
#> ! epidatr cache is being used (set env var EPIDATR_USE_CACHE=FALSE if not
#>   intended).
#> ℹ The cache directory is ~/.cache/R/epidatr.
#> ℹ The cache will be cleared after 14 days and will be pruned if it exceeds 4096
#>   MB.
#> ℹ The log of cache transactions is stored at ~/.cache/R/epidatr/logfile.txt.
library(magrittr)
today <- as.Date("2025-08-07")
analysis_as_of_date <- today - 14L
analysis_as_of_epiweek <- MMWRweek::MMWRweek(analysis_as_of_date) %>%
  {.$MMWRyear*100 + .$MMWRweek}
tbl <- pub_flusurv("network_all", "*", issues = epirange(123401, analysis_as_of_epiweek))
#> Warning: Using cached results with `as_of` within the past week (or the future!). This
#> will likely result in an invalid cache. Consider
#> ℹ disabling the cache for this session with `disable_cache` or permanently with
#>   environmental variable `EPIDATR_USE_CACHE=FALSE`
#> ℹ setting `EPIDATR_CACHE_MAX_AGE_DAYS=1` to e.g. `3/24` (3 hours).
#> This warning is displayed once every 8 hours.

Created on 2025-08-07 with reprex v2.1.1

This can be traced back to check_is_recent comparing the epiweek number with the stringified date "20250731".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions