Skip to content

Commit

Permalink
Ensure that tz is respected in sas_numeric_to_date(); test update…
Browse files Browse the repository at this point in the history
… for recent change; clarify minor breaking change for `sas_numeric_to_date()`
  • Loading branch information
billdenney committed Nov 19, 2024
1 parent 3ea931c commit 16aa4e1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ These are all minor breaking changes resulting from enhancements and are not exp

* When `tabyl()` is called on a data.frame containing labels, it now displays the label attribute as the name of the first column in the the resulting `tabyl` object (@olivroy, #394). This may break subsequent code that refers to the output of such a `tabyl` by column name. To maintain the previous behavior of ignoring variable labels, you can remove the labels with a function like `haven::zap_labels()` or `labelled::remove_labels()` before calling `tabyl()`.

* `sas_numeric_to_date()` now warns for timezones other than "UTC" due to the way that SAS loads timezones, and the default timezone for `sas_numeric_to_date()` is now "UTC" instead of "" (#583, @billdenney)

## New features

Expand All @@ -33,8 +34,6 @@ These are all minor breaking changes resulting from enhancements and are not exp

* Restyle the package and vignettes according to the [tidyverse style guide](https://style.tidyverse.org) (#548, @olivroy)

* `sas_numeric_to_date()` now warns for timezones other than "UTC" due to potential misinterpretation (#583, @billdenney)

# janitor 2.2.0 (2023-02-02)

## Breaking changes
Expand Down
2 changes: 1 addition & 1 deletion R/sas_dates.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sas_numeric_to_date <- function(date_num, datetime_num, time_num, tz = "UTC") {
has_datetime <- TRUE
}
if (has_datetime) {
ret <- as.POSIXct(datetime_num, origin = "1960-01-01", tz = "UTC")
ret <- as.POSIXct(datetime_num, origin = "1960-01-01", tz = tz)
} else if (has_date) {
ret <- as.Date(date_num, origin = "1960-01-01")
} else if (has_time) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-sas_dates.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test_that("sas_numeric_to_date", {
# Timezone warning (#583)
expect_warning(
sas_numeric_to_date(date_num = 1, time_num = 1, tz = "America/New_York"),
regexp = "`tz` in SAS does not appear to be stored with the source data; please verify timezone conversion is correct",
regexp = "SAS may not properly store timezones other than UTC. Consider confirming the accuracy of the resulting data.",
fixed = TRUE
)
})
Expand Down

0 comments on commit 16aa4e1

Please sign in to comment.