Skip to content

Commit dda298a

Browse files
committed
storing dat as POSIXct object
1 parent 7f7dafc commit dda298a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

R/read.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ short_to_longnames <- function(v, translations) {
129129
#' of the guide mustbe compatible with that of the template in which the data
130130
#' were recorded. Furthermore, the name of the template must match the template
131131
#' name in the guide when when `checkname` is `TRUE`.
132+
#' @details
133+
#' The date atomicclass is a POSIXct object in R. Hence, we can convert this
134+
#' object to a date string with format YYYY-MM-DD by using
135+
#' `format(as.POSIXct(x, tz=""), format="%Y-%m-%d")`.
132136
#' @return A list with up to three elements
133137
#' @export
134138
#'

R/utils.R

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@ has_star <- function(x) {
5050
#' @param atomicclass A character string indicating the atomic class
5151
#' @description
5252
#' We assume that the date is stored as a signed integer in excel, being the
53-
#' number of days passed since January 1 1970.
54-
# TODO: check the previous statement
53+
#' number of days passed since January 1 1970. When read by read_excel it seems
54+
#' to be converted to the number of seconds passed since January 1 1970. This
55+
#' is the same as the POSIXct class in R. Hence, we can convert this number `x`
56+
#' to a date again by using `as.POSIXct(x)` and
57+
#' `format(as.POSIXct(x, tz=""), format="%Y-%m-%d")` to get a string with format
58+
#' YYYY-MM-DD.
59+
#'
60+
# TODO: check the previous statements
5561
#' @return A vector of the specified atomic class
5662
#' @noRd
5763
coerce <- function(x, atomicclass) {
@@ -60,5 +66,6 @@ coerce <- function(x, atomicclass) {
6066
"numeric" = as.numeric(x),
6167
"integer" = as.integer(x),
6268
"logical" = as.logical(x),
63-
"date" = as.integer(x))
69+
"date" = as.POSIXct(as.integer(x))
70+
)
6471
}

man/read_data.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)