Skip to content

Ambigious time zones from read_waterdata_combined_meta() #892

@jennymurphy

Description

@jennymurphy

Describe the bug
The documentation for read_waterdata_combined_meta() states "All time values RETURNED from the service are UTC with the exception of daily data, which returns time values in local dates." However, when I query for continuous nitrate sites in Iowa the begin and end columns return date-times with an empty timezone attribute (tzone = "") but with "CDT" or "CST" listed when I print the date-time. However, the latter issue (i.e., the presence of "CDT" when preinted) may be something happening internally within RStudio because when I look at the returned data as a CSV using notepad these date-times have no timezone code with them.

To Reproduce
Steps to reproduce the behavior:

library(dataRetrieval)

# Query for instantaneous nitrate data for sites in Iowa
ia_sites_inst <- read_waterdata_combined_meta(
  state_name = "Iowa",
  parameter_code = "99133", statistic_id = "00011",
  site_type = "Stream",
  skipGeometry = TRUE
)

#tzone attribute is blank
attributes(ia_sites_inst$begin)

#when printed "CDT" is displayed though I expected UTC (which I think is actually what the time step represents)
ia_sites_inst$begin[1]

Expected behavior
I expected the tzone attribute of the begin and end columns to be "UTC" since this was querying instantaneous data. Note, this same unexpected behavior (i.e., tzone attribute is "" and when printed the date includes "CDT") is seen in the begin and end columns when I query for daily data statistic_id = "00003".

I'm hoping the timezone attribute can be populated during the retrieval with the appropriate timezone code (specifically UTC for everything but daily data). However, I understand that may be complicated if someone doesn't specify the statistic. In that case, perhaps a note in the documentation would alert a future user to this nuance. Thanks for all the amazing updates to the dataRetrieval package!

Screenshots
Here's a screenshot of that last line of code, in case it doesn't replicate for you:
Image

Session Info
R version 4.5.0 (2025-04-11 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default
LAPACK version 3.12.1

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] lubridate_1.9.5 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4
[5] purrr_1.0.4 readr_2.2.0 tidyr_1.3.1 tibble_3.3.1
[9] ggplot2_4.0.2 tidyverse_2.0.0 dataRetrieval_2.7.24

loaded via a namespace (and not attached):
[1] rappdirs_0.3.4 utf8_1.2.6 generics_0.1.4 class_7.3-23
[5] KernSmooth_2.23-26 stringi_1.8.7 hms_1.1.4 magrittr_2.0.5
[9] grid_4.5.0 timechange_0.4.0 RColorBrewer_1.1-3 jsonlite_2.0.0
[13] e1071_1.7-17 DBI_1.3.0 scales_1.4.0 httr2_1.2.2
[17] cli_3.6.6 rlang_1.2.0 units_1.0-1 withr_3.0.2
[21] otel_0.2.0 tools_4.5.0 tzdb_0.5.0 curl_7.0.0
[25] vctrs_0.7.3 R6_2.6.1 proxy_0.4-29 lifecycle_1.0.5
[29] classInt_0.4-11 pkgconfig_2.0.3 pillar_1.11.1 gtable_0.3.6
[33] data.table_1.18.4 glue_1.8.1 Rcpp_1.1.1-1.1 sf_1.1-1
[37] tidyselect_1.2.1 rstudioapi_0.17.1 farver_2.1.2 compiler_4.5.0
[41] S7_0.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions