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

fix: wrong time zones returned by strptime #42

Merged
merged 1 commit into from
Sep 17, 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
3 changes: 2 additions & 1 deletion R/grabMzmlFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ grabMzmlMetadata <- function(xml_data){
time_node <- xml2::xml_find_first(xml_data, xpath = "//d1:run")
time_val <- xml2::xml_attr(time_node, "startTimeStamp")
if(!is.na(time_val)){
time_stamp <- as.POSIXct(strptime(time_val, "%Y-%m-%dT%H:%M:%SZ"))
time_val <- sub("Z$", "+0000", time_val)
time_stamp <- as.POSIXct(strptime(time_val, "%Y-%m-%dT%H:%M:%S%z", tz="UTC"))
} else {
time_stamp <- as.POSIXct(NA)
}
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test_chroms.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ test_that("warning thrown when requesting chroms from mzXML", {
expect_warning(grabMSdata(mzXML_filenames[2], grab_what = "chroms"),
regexp = "grab_what = 'chroms' not available for mzXML documents")
})

test_that("time stamp is correct", {
expect_identical(msdata_MRM_everything$metadata$timestamp,
as.POSIXct("2022-08-11 12:34:56",tz="UTC"))
})
Loading