Skip to content

Commit

Permalink
Merge pull request #42 from ethanbass/master
Browse files Browse the repository at this point in the history
fix: wrong time zones returned by strptime - needs followup
  • Loading branch information
wkumler authored Sep 17, 2024
2 parents 5c35c7b + ae64a95 commit 158892b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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"))
})

0 comments on commit 158892b

Please sign in to comment.