Skip to content

Commit

Permalink
made an S3 method for c.POSIXlt that directs R to the lubridate S3 me…
Browse files Browse the repository at this point in the history
…thod for c.POSIXct
  • Loading branch information
garrettgman committed Apr 22, 2013
1 parent 1c3a190 commit 5b2ab9a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -12,6 +12,7 @@ S3method(as.POSIXlt,tis)
S3method(as.POSIXlt,xts)
S3method(as.POSIXlt,zoo)
S3method(c,POSIXct)
S3method(c,POSIXlt)
S3method(decimal_date,default)
S3method(decimal_date,its)
S3method(decimal_date,zoo)
Expand Down
8 changes: 7 additions & 1 deletion R/POSIXt.r
Expand Up @@ -18,5 +18,11 @@ is.POSIXlt <- function(x) is(x, "POSIXlt")
is.POSIXct <- function(x) is(x, "POSIXct")

#' @S3method c POSIXct
c.POSIXct <- function (..., recursive = FALSE)
c.POSIXct <- function (..., recursive = FALSE) {
.POSIXct(c(unlist(lapply(list(...), unclass))), tz = tz(list(...)[[1]]))
}

#' @S3method c POSIXlt
c.POSIXlt <- function (..., recursive = FALSE) {
as.POSIXlt(do.call("c.POSIXct", lapply(list(...), as.POSIXct)))
}
2 changes: 1 addition & 1 deletion R/update.r
Expand Up @@ -128,7 +128,7 @@ fit_to_timeline <- function(lt, class = "POSIXct") {
if (class != "POSIXlt" && class != "POSIXct")
stop("class argument must be POSIXlt or POSIXct")

# fall break
# fall break - DST only changes if it has to
ct <- as.POSIXct(lt)
t <- lt
t$isdst <- as.POSIXlt(ct)$isdst
Expand Down

0 comments on commit 5b2ab9a

Please sign in to comment.