Skip to content

Commit

Permalink
format bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
philipdelff committed Aug 26, 2024
1 parent 8d224ac commit d65dafd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions tests/testthat/test_NMorderColumns.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ test_that("Non-numeric DATE and TIME",{

fileRef <- "testReference/NMorderColumns_02.rds"

pk <- readRDS(file="testData/data/xgxr2.rds") |> setDT()
pk <- readRDS(file="testData/data/xgxr2.rds")
setDT(pk)

pk[,time.tz:=as.POSIXct("2000/01/01",tz="UTC")+TIME*3600]
## pk[,DATE:=as.character(as.Date(time.tz),format="%y/%m/%d")]
## pk[,TIME:=as.character(time.tz,format="%H:%M:%S")]

pk[,DATE:=print.Date(time.tz,format="%y/%m/%d")]
pk[,TIME:=print.POSIXct(time.tz,format="%H:%M:%S")]
pk[,DATE:=format(as.Date(time.tz),format="%y/%m/%d")]
pk[,TIME:=format(time.tz,format="%H:%M:%S")]


pk1 <- NMorderColumns(pk)
Expand Down
12 changes: 9 additions & 3 deletions tests/testthat/test_NMwriteData.R
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,14 @@ test_that("save csv and fst",{

test_that("Non-numeric DATE and TIME",{



fileRef <- "testReference/NMwriteData_13.rds"
outfile <- "testOutput/NMwriteData_13.csv"

pk <- readRDS(file="testData/data/xgxr2.rds") |> setDT()

## pk <- fix.input(pk)

pk[,time.tz:=as.POSIXct("2000/01/01")+TIME*3600]
## pk[,DATE:=as.character(as.Date(time.tz),format="%y/%m/%d")]
pk[,DATE:=format(as.Date(time.tz),format="%y/%m/%d")]
Expand All @@ -324,12 +325,17 @@ test_that("Non-numeric DATE and TIME",{
nmcode <- NMwriteData(pk,file=outfile
,script="DATE and TIME as char",formats=cc(csv),
args.stamp=list(time="2021-11-21 11:00:00"))
res1 <- NMreadCsv(fnExtension(outfile,"csv"),as.fun="data.table")

res <- NMreadCsv(fnExtension(outfile,"csv"),as.fun="data.table")


expect_equal_to_reference(
res1
res
,fileRef,version=2)

if(F){
ref <- readRDS(fileRef)
compareCols(res,ref)
}

})

0 comments on commit d65dafd

Please sign in to comment.