Skip to content
Prev 61104 / 63424 Next

Bug with `[<-.POSIXlt` on specific OSes

Exactly.  Debugging `[<-.POSIlt` with

x <- as.POSIXlt(as.POSIXct("2013-01-31", tz = "America/Chicago"))
Sys.setenv(TZ = "UTC")
x[1] <- NA

shows we get into

    value <- unclass(as.POSIXlt(value))
    if (ici) {
        for (n in names(x)) names(x[[n]]) <- nms
    }
    for (n in names(x)) x[[n]][i] <- value[[n]]

where

Browse[2]> names(value)
[1] "sec"   "min"   "hour"  "mday"  "mon"   "year"  "wday"  "yday"  "isdst"
Browse[2]> names(x)
 [1] "sec"    "min"    "hour"   "mday"   "mon"    "year"   "wday"   "yday"  
 [9] "isdst"  "zone"   "gmtoff"

Without having looked at the code, the docs say

     ?zone? (Optional.) The abbreviation for the time zone in force at
          that time: ?""? if unknown (but ?""? might also be used for
          UTC).

     ?gmtoff? (Optional.) The offset in seconds from GMT: positive
          values are East of the meridian.  Usually ?NA? if unknown,
          but ?0? could mean unknown.

so perhaps we should fill with the values for the unknown case?

-k