Skip to content
Prev 14128 / 63461 Next

POSIX time anomaly (PR#7317)

Full_Name: Allen McIntosh
Version: 2.0.0
OS: RedHat 9.0
Submission from: (NULL) (67.80.175.118)


The POSIX time printing routine gives strange results when asked to print a time
that is exactly midnight:

TZ=CST6CDT R -q --no-save
[1] "2004-10-05 00:00:01"
[1] "2004-10-05"
[1] NA 

The first time is OK.  The second is missing the HH:MM:SS.
I'm OK with the last one being NA, just did it to see if that was the way that
the code wanted midnight.

Get the underlying # seconds:
[1] 1096952400
attr(,"tzone")
[1] ""
and (just to see if the problem is glibc or something):
$ cat ct.c
#include <time.h>
#include <stdio.h>
main() {
        time_t z = 1096952400;
        printf("%s\n", ctime(&z));
        return 0;
}
$ gcc -o ct ct.c
$ TZ=CST6CDT ./ct
Tue Oct  5 00:00:00 2004

This problem also observed with R 1.6.0 and R 1.8.1 (RedHat 7.3)
The timezone doesn't seem to matter - this is just the first date that tripped
over this problem.