Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address tzdata breaking changes #64

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Minor changes

* timezones for converted OceanOptics files are now handled differently internally (@Bisaloo, #64),
to handle changes in upstream tzdata 2024b, which removed for example the CET and EST timezone codes.
This may result in some other deprecated timezone codes not being handled correctly.
Please report any bugs or discrepancies you may notice in the `datetime` field of metadata.
* lightr now depends on R >= 4.0.0, following the tidyverse recommendation
* the future package is now explicitly listed as a dependency, removing an `R CMD check` `NOTE` and thus removing the strain on CRAN reviewers.
The future package was already a indirect dependency via the future.apply package.
Expand Down
2 changes: 1 addition & 1 deletion R/parse_avantes_binary.R
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ lr_parse_rfl8 <- function(filename, specnum = 1L) {
dark_boxcar, white_boxcar, scope_boxcar)

if (specnum == i) {
return(list("data" = data, "metadata" = metadata))
return(list(data = data, metadata = metadata))
}

}
Expand Down
2 changes: 1 addition & 1 deletion R/parse_avantes_converted.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ lr_parse_ttt <- function(filename) {

data_final[match(colnames(data), cornames)] <- data

return(list("data" = data_final, "metadata" = metadata))
return(list(data = data_final, metadata = metadata))
}

#' @rdname lr_parse_ttt
Expand Down
5 changes: 4 additions & 1 deletion R/parse_oceanoptics_converted.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,16 @@ lr_parse_jaz <- function(filename) {
tz <- ""

if (grepl(oo_savetime_regex, savetime)) {
# The value we extract here might not follow the official naming and could
# not be recognized by tzdata.
tz <- trimws(gsub(oo_savetime_regex, "\\2", savetime))
savetime <- gsub(oo_savetime_regex, "\\1 \\3", savetime)
}

if (tz == "") {
tz <- "UTC"
}
tz <- convert_backward_tzdata(tz)

# OceanOptics files use locale-dependent date formats but it looks like they
# are always using English for this, even when the locale is not set to
Expand Down Expand Up @@ -163,7 +166,7 @@ lr_parse_jaz <- function(filename) {

data_final[match(colnames(data), cornames)] <- data

return(list("data" = data_final, "metadata" = unname(metadata)))
return(list(data = data_final, metadata = unname(metadata)))
}

#' @rdname lr_parse_jaz
Expand Down
2 changes: 1 addition & 1 deletion R/parse_spc.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ lr_parse_spc <- function(filename) {

metadata <- rep(NA_character_, 13)

return(list("data" = as.data.frame(data), "metadata" = metadata))
return(list(data = as.data.frame(data), metadata = metadata))

}
15 changes: 15 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,18 @@
ifelse(int32 >= 0, int32, 2^31 - 1 + int32)

}

convert_backward_tzdata <- function(tz) {

# Convert timezones removed in tzdata 2024b.
# This is a subset of what tzdata-backward is providing, based on cases we
# could observe in test files. It can be expanded based on user feedback and
# new test files.
switch(
tz,
EST = "America/Panama",
CET = "Europe/Brussels",

Check warning on line 16 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L16

Added line #L16 was not covered by tests
tz
)

}