Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add error catch for cdec_query start_date and end_date arguments #47

Closed
mkoohafkan opened this issue Sep 25, 2018 · 0 comments
Closed

Comments

@mkoohafkan
Copy link

mkoohafkan commented Sep 25, 2018

Due to this purrr issue (which may be fixed in the next release), using purrr::pmap with cdec_query can cause unexpected results when Date classes are passed to the start_date and/or end_date arguments to cdec_query. purrr:pmap strips the Date class prior to calling the function, which means cdec_query gets integer values for start_date/end_date rather than Date classes. For some reason this doesn't cause an error, it just ignores the start/end specs.

It would be great if cdec_query could have an error catch that makes sure the start_date or end_date arguments are either character or date classes. The simplest solution would probably be to make this change to query_url:

query_url <- glue::glue(cdec_urls$download_shef, STATION = station,
SENSOR = as.character(sensor_num), DURCODE = as.character(dur_code),
STARTDATE = as.character(as.Date(start_date)), ENDDATE = as.character(as.Date(end_date)))

Which would cause cdec_query to error out when trying to convert an integer to a date without an origin.

@ergz ergz closed this as completed May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants