Skip to content
Prev 14129 / 63461 Next

POSIX time anomaly (PR#7317)

This is intentional: why did you send a bug report?  Please read the 
section on BUGS in the FAQ and tell us how this contradicts the 
documentation.

If you want a particular output format, you need to specify it:

x <- strptime("10/5/2004 00:00:00 CDT", "%m/%d/%Y %H:%M:%S %Z")
format(x, "%Y-%m-%d %H:%M:%S")
[1] "2004-10-05 00:00:00"

but print() is allowed to suppress 0's.  Did you bother to read the code:
function (x, format = "", usetz = FALSE, ...)
{
    if (!inherits(x, "POSIXlt"))
        stop("wrong class")
    if (format == "") {
        times <- unlist(unclass(x)[1:3])
        format <- if (all(times[!is.na(times)] == 0))
            "%Y-%m-%d"
        else "%Y-%m-%d %H:%M:%S"
    }
    .Internal(format.POSIXlt(x, format, usetz))
}

?
On Thu, 28 Oct 2004 mcintosh@research.telcordia.com wrote:

            
We don't need your permission: this is as documented.
What has ctime() to do with this?