diff --git a/R/add_context.R b/R/add_context.R index 6915571..1083b8e 100644 --- a/R/add_context.R +++ b/R/add_context.R @@ -5,8 +5,8 @@ add_context <- function(data, id, name, created_date, modified_date) { } # Parse the date values - created_date <- strptime(created_date, format = "%FT%X", tz = "UTC") - modified_date <- strptime(modified_date, format = "%FT%X", tz = "UTC") + created_date <- as.POSIXct(created_date, format = "%FT%X", tz = "UTC") + modified_date <- as.POSIXct(modified_date, format = "%FT%X", tz = "UTC") # The platform can record the modified date as being before the created date # by a few microseconds, this will catch any rounding which ensure diff --git a/tests/testthat/test-add_context.R b/tests/testthat/test-add_context.R index aa1ef35..44580f8 100644 --- a/tests/testthat/test-add_context.R +++ b/tests/testthat/test-add_context.R @@ -19,25 +19,6 @@ test_that("Returned context is the same for resource and dataset", { include_context = TRUE ) - # --- Remove from here - # This code works around an issue with vctrs - # https://github.com/r-lib/vctrs/issues/1930 - dataset_has_POSIXlt <- inherits(dataset$res_created_date, "POSIXlt") - - # If this test fails, that's good (probably) and this can all be removed - expect_error(stopifnot(dataset_has_POSIXlt)) - - if (!dataset_has_POSIXlt) { - dataset <- dataset %>% - dplyr::mutate( - dplyr::across( - c("res_created_date", "res_modified_date"), - as.POSIXlt - ) - ) - } - # --- Remove to here - expect_equal( dataset %>% dplyr::filter(res_id == res_id_1) %>% diff --git a/tests/testthat/test-get_dataset_context.R b/tests/testthat/test-get_dataset_context.R index 2ad2182..e16a39a 100644 --- a/tests/testthat/test-get_dataset_context.R +++ b/tests/testthat/test-get_dataset_context.R @@ -18,6 +18,11 @@ test_that("returns expected context with the data", { ) expect_s3_class(data, "tbl_df") + expect_type(data$res_id, "character") + expect_type(data$res_name, "character") + expect_s3_class(data$res_created_date, "POSIXct") + expect_s3_class(data$res_modified_date, "POSIXct") + expect_equal(nrow(data), n_resources * n_rows) expect_length(data, 28) expect_named( diff --git a/tests/testthat/test-get_resource_context.R b/tests/testthat/test-get_resource_context.R index 504855c..20f7ebc 100644 --- a/tests/testthat/test-get_resource_context.R +++ b/tests/testthat/test-get_resource_context.R @@ -14,8 +14,8 @@ test_that("returns expected context with the data", { expect_s3_class(data, "tbl_df") expect_type(data$res_id, "character") expect_type(data$res_name, "character") - expect_s3_class(data$res_created_date, "POSIXlt") - expect_s3_class(data$res_modified_date, "POSIXlt") + expect_s3_class(data$res_created_date, "POSIXct") + expect_s3_class(data$res_modified_date, "POSIXct") expect_length(data, 19) expect_equal(nrow(data), 10)