-
Notifications
You must be signed in to change notification settings - Fork 115
Closed
Labels
featurea feature request or enhancementa feature request or enhancement
Description
I noticed that haven exports datetimes as UTC regardless of timezone (which I do not think needs to change). However, I think it helpful for the UTC conversion to be explicit. E.g., with either a message in R if there is a non-UTC datetime, or a note in the documentation. Small issue, but some haven users may not realize they are exporting their datetime as UTC.
Exemplified here:
library(haven)
library(tibble)
test = tibble(date = as.Date("1999-12-31 22:00"),
time = readr::parse_time("22:00"),
date_time_edt = as.POSIXct("1999-12-31 22:00 EST"), # haven quietly coerces to UTC for date-time
date_time_utc = as.POSIXct("1999-12-31 22:00", tz = "UTC"))
# SPSS
spss_tmpfile = tempfile(fileext = ".sav")
write_sav(test, spss_tmpfile)[]
read_sav(spss_tmpfile)
# SAS
sas_tmpfile = tempfile(fileext = ".sas7bdat")
write_sas(test, sas_tmpfile)[]
read_sas(sas_tmpfile)
# STATA
stata_tmpfile = tempfile(fileext = ".dta")
write_dta(test, stata_tmpfile)[]
read_dta(stata_tmpfile) # side-note, check "time" column on import. you may be aware but I don't use stata, so I am not sure
# Cleanup
ls(pattern = "_tmpfile") # just to make sure I don't remove anything unintended from your env
file.remove(unlist(mget(ls(pattern = "_tmpfile"))))
rm(list = ls(pattern = "_tmpfile"))
Related:
#25
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancement