atorus-research / datasetjson

Read and write CDISC Dataset JSON files
https://atorus-research.github.io/datasetjson/
Apache License 2.0
12 stars 2 forks source link

Verify date origin and create function to properly set numeric dates #1

Closed mstackhouse closed 11 months ago

mstackhouse commented 1 year ago

Numeric data in data: 19906

Character date in data: "2014-07-02"

Numeric dates supplied in R should properly convert origins

mstackhouse commented 12 months ago
> as.Date(19906)
[1] "2024-07-02"
> as.Date(19906, '1960-01-01')
[1] "2014-07-02"
mstackhouse commented 12 months ago
> test_dt <- 19906 * 24 * 60 * 60 + (2 * 60 * 60) + (45 * 60) + 20
> as.POSIXct(test_dt, origin="1970-01-01")
[1] "2024-07-02 02:45:20 UTC"