On Aug 18, 2010, at 6:23 PM, Gabor Grothendieck wrote: > No one answered this so I submitted it to the bugs system and there I > got the response that it is documented behavior; however, whether its > documented or not is hardly the point -- its undesirable that tzone is > lost when using c. >
That's one man's opinion - from docs if you want to specify an object in a particular timezone but to be printed in the current timezone you may want to remove the ‘"tzone"’ attribute (e.g. by ‘c(x)’). so apparently that is a design choice and hence I doubt it can be changed as it would break code that uses that feature. As many things in R whether it was a good choice is up for debate but it has been made already. (Think about how you would combine different times with different tzones - there is no "right" way to do so and thus stripping is very plausible and consistent) Cheers, Simon > On Thu, Aug 12, 2010 at 11:33 AM, Gabor Grothendieck > <ggrothendi...@gmail.com> wrote: >> Currently if x1 and x2 are POSIXct then c(x1, x2) will not have a >> tzone attribute even if x1 or x2 or both do but it should. >> >> This could be fixed with the following c.POSIXct: >> >> c.POSIXct <- function (..., recursive = FALSE) { >> tzones <- lapply(list(...), attr, which = "tzone") >> lengths <- sapply(tzones, length) >> if (any(lengths > 1)) stop("tzone cannot have length greater than 1") >> which <- sapply(tzones, length) == 1 >> tzone <- unique(unlist(tzones[which])) >> if (length(tzone) != 1) tzone <- NULL >> structure(c(unlist(lapply(list(...), unclass))), class = c("POSIXt", >> "POSIXct"), tzone = tzone) >> } >> >> # test >> x1 <- Sys.time() >> x2 <- structure(x1, tzone = "UTC") >> x3 <- structure(x1, tzone = "other") >> >> # these all currently give NULL but with >> # above give indicated value >> >> attr(c(x1, x1), "tzone") # NULL >> attr(c(x2, x2), "tzone") # "UTC" >> attr(c(x1, x2), "tzone") # "UTC" >> attr(c(x2, x1), "tzone") # "UTC" >> attr(c(x1, x2, x3), "tzone") # NULL >> > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel