Skip to content

Commit

Permalink
pass datetime_created to genBaseCore()
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Jul 20, 2023
1 parent f07bb92 commit 7412da5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions R/baseXML.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,18 @@ genBaseApp <- function() {
)
}

genBaseCore <- function(creator = "", title = NULL, subject = NULL, category = NULL) {
genBaseCore <- function(creator = "", title = NULL, subject = NULL, category = NULL, datetimeCreated = NULL) {

if (length(creator) > 1) creator <- paste0(creator, collapse = ";")
if (is.null(datetimeCreated)) datetimeCreated <- Sys.time()

dc_creator <- xml_node_create("dc:creator", xml_children = creator)
cp_lastMod <- xml_node_create("cp:lastModifiedBy", xml_children = creator)
dc_terms <- xml_node_create("dcterms:created",
xml_attributes = c(
`xsi:type` = "dcterms:W3CDTF"
),
xml_children = format(as_POSIXct_utc(Sys.time()), "%Y-%m-%dT%H:%M:%SZ")
xml_children = format(as_POSIXct_utc(datetimeCreated), "%Y-%m-%dT%H:%M:%SZ")
)

dc_title <- NULL
Expand Down
12 changes: 6 additions & 6 deletions R/class-workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ wbWorkbook <- R6::R6Class(
#' @param ... additional arguments
#' @return a `wbWorkbook` object
initialize = function(
creator = NULL,
title = NULL,
subject = NULL,
category = NULL,
creator = NULL,
title = NULL,
subject = NULL,
category = NULL,
datetime_created = Sys.time(),
theme = NULL,
theme = NULL,
...
) {

Expand Down Expand Up @@ -7159,7 +7159,7 @@ wbWorkbook <- R6::R6Class(

generate_base_core = function() {
# how do self$datetimeCreated and genBaseCore time differ?
self$core <- genBaseCore(creator = self$creator, title = self$title, subject = self$subject, category = self$category)
self$core <- genBaseCore(creator = self$creator, title = self$title, subject = self$subject, category = self$category, datetimeCreated = self$datetimeCreated)
invisible(self)
},

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-class-workbook-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test_that("wb_set_creators() is a wrapper", {

test_that("wb_remove_creators() is a wrapper", {
wb <- wb_workbook(creator = "myself")
expect_wrapper("remove_creators", params = list(creators = "myself"))
expect_wrapper("remove_creators", wb = wb, params = list(creators = "myself"))
})

# wb_set_last_modified_by() ---------------------------------------------------
Expand Down

0 comments on commit 7412da5

Please sign in to comment.