On 5/21/2010 4:00 AM, Julian Burgos wrote:
Hi Brian,

This is really odd.  I keep getting the NA secs answer, only by running
these three lines of code in a new session.


time3=strptime("2009 06 01 00 47 00",format="%Y %m %d %H %M")
time4=strptime("2009 06 01 00 57 00",format="%Y %m %d %H %M")
diff(c(time3,time4))
Time difference of NA secs

Here is the information you requested:

dput(time3)
structure(list(sec = 0, min = 47L, hour = 0L, mday = 1L, mon = 5L,
     year = 109L, wday = 1L, yday = 151L, isdst = -1L), .Names = c("sec",
"min", "hour", "mday", "mon", "year", "wday", "yday", "isdst"
), class = c("POSIXt", "POSIXlt"))
dput(time4)
structure(list(sec = 0, min = 57L, hour = 0L, mday = 1L, mon = 5L,
     year = 109L, wday = 1L, yday = 151L, isdst = -1L), .Names = c("sec",
"min", "hour", "mday", "mon", "year", "wday", "yday", "isdst"
), class = c("POSIXt", "POSIXlt"))
sessionInfo()
R version 2.11.0 (2010-04-22)
i386-pc-mingw32

locale:
[1] LC_COLLATE=Icelandic_Iceland.1252  LC_CTYPE=Icelandic_Iceland.1252
[3] LC_MONETARY=Icelandic_Iceland.1252 LC_NUMERIC=C
[5] LC_TIME=Icelandic_Iceland.1252

attached base packages:
[1] grDevices datasets  splines   graphics  stats     tcltk     utils
[8] methods   base

other attached packages:
[1] svSocket_0.9-48 TinnR_1.0.3     R2HTML_2.0.0    Hmisc_3.7-0.1
[5] survival_2.35-8

loaded via a namespace (and not attached):
[1] cluster_1.12.3 grid_2.11.0    lattice_0.18-5 svMisc_0.9-57
tools_2.11.0

I don't know exactly what is going on, but this at least gives me an idea. It looks to be related to timezones and daylight savings times. The difference between your dput outputs and mine is that yours has the isdst = -1L and mine had isdst = 1L. However, even if I used your exact structure from the dput, I still get "Time difference of 10 mins". I have seen isdst=-1L before, and usually it is when there is ambiguity as to whether the time is in daylight savings time or not. I don't know anything about Iceland with regards to DST (Wikipedia says they don't observe it, for what that is worth).

It seems you have a locale/timezone/DST interaction happening somehow. What happens if you explicitly set the timezone using tz in strptime? Beyond that, I don't have any further ideas of how to fix it.

Thanks,

Julian

--
Brian Diggs
Senior Research Associate, Department of Surgery, Oregon Health & Science University

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to