You haven't given us the 'at a minimum' information that the posting guide requested, so we don't know your timezone. But in America/Toronto on my F8 machine

d <- "2007-11-04 01:30:00"
dd <- as.POSIXct(d)
c(dd, dd+3600)

[1] "2007-11-04 01:30:00 EDT" "2007-11-04 01:30:00 EST"

Note the change of timezone. Wikipedia says that is the right day for Canada ('from 2:00 a.m. LDT to 1:00 LST on the first Sunday in November since 2007'). Note that 01:34 is ambiguous that day (see ?as.POSIXct, surely part of the required homework).

The N American late change in rules in 2007 means that DST changes can be unreliable in OSes, but this one seems to be correct.

I do believe that you have failed to credit the careful work in getting this right in R. Perhaps these are not times in Ontario and you forgot to tell R that?

On Thu, 14 Aug 2008, Bill Szkotnicki wrote:

Hi,
I am computing some time differences.
Using the linux version of R 2.7.1
And I am getting a strange result ( see below )
I need the difference in minutes.
Actually looking for where it is NOT 15 minutes.
Would anyone know why this could be  happening?
Or should I do this another way?

Bill

The script "k0.R"
===============
a=read.table("buzwah005.txt")
d=strptime(paste(a[,1]," ",a[,2]),"%m/%d/%Y %H:%M")
tm=-24*60*as.numeric(as.POSIXlt("2007-1-1")-d) # time since midnight Jan 1
print(tm[2]-tm[1])
x=a[,3]
diffs=round(tm[-1]-tm[-length(tm)])
not15=(1:length(diffs))[diffs!=15]
print(not15)
===============

The R session....

source("k0.R")
[1] 15
[1]  2113  5686 15712
class(d)
[1] "POSIXt"  "POSIXlt"
d[15711:15714]
[1] "2007-11-04 01:34:00" "2007-11-04 01:49:00" "2007-11-04 02:04:00"
[4] "2007-11-04 02:19:00"
d[15712]-d[15711]
Time difference of 15 mins
d[15713]-d[15712]
Time difference of 1.25 hours
d[15714]-d[15713]
Time difference of 15 mins



______________________________________________
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.


--
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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