[R] ISOdate returns incorrect date?
Heiko Schaefer
heiko.schaefer at swissrisk.com
Wed Nov 19 17:48:00 CET 2003
You are on the right track. I suppose that linux and windows use 32 bit
For time_t and we go back beyond a valid date. Try this code:
#include <stdio.h>
#include <time.h>
int main() {
struct tm a;
time_t b;
strptime("1900-03-15 12:00:00","%Y-%m-%d %H:%M:%S",&a);
printf("%s\n",asctime(&a));
// now go via time_t
b = mktime(&a);
printf("%s\n",ctime(&b));
}
And if we go via time_t we get unix epoch 0 back. Somehow R manages
To be less wrong then the OS, but still wrong....
Heiko
-----Original Message-----
From: Peter Dalgaard [mailto:p.dalgaard at biostat.ku.dk]
Sent: Mittwoch, 19. November 2003 17:46
To: heiko.schaefer at swissrisk.com
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] ISOdate returns incorrect date?
"Heiko Schaefer" <heiko.schaefer at swissrisk.com> writes:
> Does this really work for you? I still get:
> > ISOdate(1900,6,16)
> [1] "1900-06-15 14:00:00 Westeuropäische Sommerzeit"
> > ISOdate(1900,6,16,tz="")
> [1] "1900-06-15 12:00:00 Westeuropäische Sommerzeit"
>
> Obviously the time son influences the time, but it can
> Not possibly account for the difference of a full day?!
>
> Still puzzled...
Yes, something is strange for me too (RedHat 8):
> ISOdate(1900,3,1)
[1] "1900-03-01 13:00:00 CET"
> ISOdate(1900,3,2)
[1] "1900-03-01 13:00:00 CET"
Apparently, the one-day shift affects all dates after March 2, 1900, and
in no other year. One easily gets the suspicion that the fact that 1900
was *not* a leap year has something to do with it. However,
strptime() which this calls indirectly is only as good as its OS-level
counterpart, I believe.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list