[Rd] Revisit c.POSIXlt , [<-.POSIXlt , [[<-.POSIXlt ?

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Mon Jun 15 18:08:43 CEST 2026


>>>>> Suharto Anggono Suharto Anggono 
>>>>>     on Sun, 14 Jun 2026 13:37:13 +0000 (UTC) writes:

    > Could at least a minimalistic fix be put for the upcoming R 4.6.1? For example:
    > ln '[<-.POSIXlt' and '[[<-.POSIXlt', change
    >     else as.POSIXlt(as.POSIXct(value), tz = tz[1L]))
    > to
    >     else as.POSIXlt(as.POSIXct(value), tz = if(is.null(tz)) "" else tz[1L]))

    > In 'c.POSIXlt', apply 'floor' to the 'sec' component before converting to POSIXct like in Bug 18989 Comment 9 (https://bugs.r-project.org/show_bug.cgi?id=18989#c9).


Yes, this *could* be done, last minute, i.e., fixing some bugs
in POSIXlt <--> POSIXct  handling.

I've tried in my local copy of  "R 4.6.1 beta".

and indeed, these minimal patches already fix the two problems
you mention below (and I've marked with  '1.'  and '2.' ).

*However* your wish is rather late (we have code freeze in 1.5 days and
should only fix somewhat urgent problems with small fixes), 
*and* the two problematic examples below are not new bugs, they
do "not work" already in 4.4.x (I tried one) and 4.5.0, .. 4.5.3, etc

Whereas your proposed changes *are* nicely small and look
sensible, the bugs (below) have been in R for a while now *and*
are fixed in R-devel (already with svn r89926 I think).

So I don't know if there is anybody (but you ;-) who'd be very
happy for such a late bug fix.

Other opinions -- notably R core / Release Manager ?

Thank you in any case, for the suggestion, and the effort to
find such a minimal (informal) patch.

Best regards,
Martin


    > ______
    > On Friday, 17 April 2026 at 02:13:48 pm GMT+7, Suharto Anggono Suharto Anggono <suharto_anggono using yahoo.com> wrote:


    > One more thing.

    > A POSIXlt object without 'tzone' attribute (attr(*, "tzone") is NULL) is valid.

    > If 'x' is a POSIXct object,
    > as.POSIXlt(x, tz = NULL)
    > uses 'tzone' attribute of 'x', same as
    > as.POSIXlt(x) .

    > So, with current '[<-.POSIXlt' in R devel and R 4.6.0 RC, subassigning a POSIXct object without 'tzone' attribute to a POSIXlt object without 'tzone' attribute gives error. For example,

1.
    > x1 <- as.POSIXlt(Sys.time()); attr(x1, "tzone") <- NULL
    > x1[1L] <- Sys.time()

    > Additionally, after

2.
    > x1 <- as.POSIXlt(Sys.time()); attr(x1, "tzone") <- NULL; x2 <- x1
    > y1 <- as.POSIXlt(.POSIXct(0, tz = "UTC"))
    > y2 <- as.POSIXlt(.POSIXct(0, tz = "America/Toronto"))
    > x1[1L] <- y1
    > x2[1L] <- y2

    > , either
    > x1[1L] - y1
    > or
    > x2[1L] - y2
    > (or both) is not 0.



More information about the R-devel mailing list