Skip to content

Commit

Permalink
Closes #316 remove messaging that includes "-" as year not handled (#317
Browse files Browse the repository at this point in the history
)

* feat: #316 remove messaging that includes "-" as year not handled

* feat: #316 replace warning message

* chore: #316 fix warning message and typos

* chore: #316 add news blurb

---------

Co-authored-by: Zelos Zhu <[email protected]>
  • Loading branch information
zdz2101 and Zelos Zhu authored Aug 30, 2023
1 parent 0a278a8 commit c3d1237
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## Updates of Existing Functions

- The messaging for `warn_if_invalid_dtc()` was updated to align with what the date/datetime functions in `admiral` currently do. (#316)

## Breaking Changes

- The following functions/arguments have been deprecated from previous admiral versions using the next phase of the deprecation process: (#288)
Expand Down
18 changes: 4 additions & 14 deletions R/warnings.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,10 @@ warn_if_invalid_dtc <- function(dtc, is_valid = is_valid_dtc(dtc)) {
)

info <- paste0(
"The following ISO representations are handled: \n",
"2003-12-15T13:15:17.123\n",
"2003-12-15T13:15:17\n",
"2003-12-15T13:15\n",
"2003-12-15T13\n",
"2003-12-15\n",
"2003-12\n",
"2003\n",
"2003---15\n\n",
"The following ISO representations, and any other representation are NOT handled: \n",
"2003-12-15T-:15:18\n",
"2003-12-15T13:-:19\n",
"--12-15\n",
"-----T07:15"
"ISO representations of the form YYYY-MM-DDThh:mm:ss.ddd are expected, ",
"e.g., 2003-12-15T13:15:17.123. Missing parts at the end can be omitted. ",
"Missing parts in the middle must be represented by a dash, e.g., 2003---15.",
sep = "\n"
)
warn(paste(main_msg, tbl, info, sep = "\n"))
}
Expand Down
7 changes: 4 additions & 3 deletions tests/testthat/test-warnings.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ test_that("warn_if_vars_exist Test 1: warning if a variable already exists in th
)
})

# warn_if_invalud_dtc ----
# warn_if_invalid_dtc ----
## Test 2: Warning if vector contains unknown datetime format ----
test_that("warn_if_invalud_dtc Test 2: Warning if vector contains unknown datetime format", {
test_that("warn_if_invalid_dtc Test 2: Warning if vector contains unknown datetime format", {
expect_warning(
warn_if_invalid_dtc(dtc = "20210406T12:30:30")
warn_if_invalid_dtc(dtc = "20210406T12:30:30"),
"Dataset contains incorrect datetime format:"
)
})

Expand Down

0 comments on commit c3d1237

Please sign in to comment.