Skip to content

Commit

Permalink
Rename convertToExcelDate (#672)
Browse files Browse the repository at this point in the history
* convertToExcelDate -> convert_to_excel_date

* Update example

* Fixed deprecation

---------

Co-authored-by: Jan Marvin Garbuszus <jan.garbuszus@ruhr-uni-bochum.de>
  • Loading branch information
olivroy and JanMarvin authored Jul 2, 2023
1 parent 2b2267a commit 8d3ad5d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(convertToExcelDate)
export(convert_date)
export(convert_datetime)
export(convert_hms)
export(convert_to_excel_date)
export(create_border)
export(create_cell_style)
export(create_comment)
Expand Down
10 changes: 8 additions & 2 deletions R/dates.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ conv_to_excel_date <- function(x, date1904 = FALSE) {
#' wb1 <- wb_load(xlsxFile)
#' df <- wb_to_df(wb1)
#' # conversion is done on dataframes only
#' convertToExcelDate(df = df["Var5"], date1904 = FALSE)
#' convert_to_excel_date(df = df["Var5"], date1904 = FALSE)
#' @export
convertToExcelDate <- function(df, date1904 = FALSE) {
convert_to_excel_date <- function(df, date1904 = FALSE) {

is_date <- vapply(
df,
Expand All @@ -227,3 +227,9 @@ convertToExcelDate <- function(df, date1904 = FALSE) {

df
}
#' @export
#' @rdname convert_to_excel_date
convertToExcelDate <- function(df, date1904 = FALSE) {
.Deprecated(old = "convertToExcelDate", new = "convert_to_excel_date", package = "openxlsx2")
convert_to_excel_date(df = df, date1904 = date1904)
}
2 changes: 1 addition & 1 deletion R/write.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ write_data2 <- function(
ignore.case = TRUE)

# TODO need to tell excel that we have a date, apply some kind of numFmt
data <- convertToExcelDate(df = data, date1904 = hconvert_date1904)
data <- convert_to_excel_date(df = data, date1904 = hconvert_date1904)

# backward compatible
if (!inherits(data, "data.frame") || inherits(data, "matrix")) {
Expand Down
7 changes: 5 additions & 2 deletions man/convertToExcelDate.Rd → man/convert_to_excel_date.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-wb_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_that("wb_to_df", {

# do not try to identify dates in the data
got <- wb_to_df(wb1, detectDates = FALSE)
expect_equal(convertToExcelDate(df = exp["Var5"], date1904 = FALSE),
expect_equal(convert_to_excel_date(df = exp["Var5"], date1904 = FALSE),
got["Var5"])

# return the underlying Excel formula instead of their values
Expand Down

0 comments on commit 8d3ad5d

Please sign in to comment.