Re: [R] time zones in POSIXt
I think this is a problem with difftime (which gets called when the subtraction in your example is invoked). The first few lines of difftime are: function (time1, time2, tz = , units = c(auto, secs, mins, hours, days, weeks)) { time1 - as.POSIXct(time1, tz = tz) time2 - as.POSIXct(time2, tz = tz) so any POSIXlt timezone gets clobbered with difftime's tz. Vadim Ogranovich vograno at evafunds.com writes: : : Hi, : : I have two data sources. One records time in PST time zone, the other in : GMT. I want to compute the difference between the two, but don't see : how. Here is an example where I compute time difference between : identical times each (meant to be) relative to its time zone. : : as.POSIXlt(2000-05-10 10:15:00, PST) - as.POSIXlt(2000-05-10 : 10:15:00, GMT) : Time difference of 0 secs : : I was expecting to see 8hrs (which is the time difference between London : and San-Francisco). Why is it so and what is the correct way of doing : it? : : I use R-1.8.1 on RH-7.3. : : Thanks, : Vadim : : : [[alternative HTML version deleted]] : : __ : R-help at stat.math.ethz.ch mailing list : https://www.stat.math.ethz.ch/mailman/listinfo/r-help : PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html : : __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] time zones in POSIXt
On Fri, 23 Apr 2004, Vadim Ogranovich wrote: Thank you for the lead, Dirk! Indeed this works on my machine too: as.POSIXct(2000-05-10 10:15:00, tz=PST8PDT) - as.POSIXct(2000-05-10 10:15:00, tz=GMT) Time difference of 7 hours However when I replace POSIXct by POSIXlt it breaks (this looks like a bug to me): as.POSIXlt(2000-05-10 10:15:00, tz=PST8PDT) - as.POSIXlt(2000-05-10 10:15:00, tz=GMT) Time difference of 0 secs No, it's not a bug. POSIXlt times are just numeric representations of broken-down times, and the tzone attribute (which is normally not present) is just a reminder to you. (It has not been checked, so this is avoid nasty surprises if it is wrong.) Maybe it was a bad idea to allow - for POSIXlt times, but then we do expect users to read the documentation (including the code if they are puzzled). Now a couple of new questions: * how could I learn about appropriate names for time zones? For example I was using PST whereas it seems I had to use either PST8 or PST8PDT. Why PST was not good? Is it documented anywhere? Specific to your OS, so I expect it documents it somewhere. * there seems to be no difference betweeen GMT and BST on my machine though PST8 and PST8PDT are treated properly: # PST8 is not identical to PST8PDT ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz=PST8) - ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz=PST8PDT) Time differences of0,0,0,0, 3600, 3600, 3600, 3600, 3600, 3600,0,0 secs # GMT0 is identical to BST ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz=GMT0) - ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz=BST) Time differences of 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 secs Why is such dichotomy? Ask your OS designer - timezones are handled by your OS. I would not consider BST to be a timezone as it is only defined for half the year. Windiows thinks I am on `GMT Daylight Time' although that usage is otherwise unknown in this country. -- 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, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] time zones in POSIXt
Prof Brian Ripley ripley at stats.ox.ac.uk writes: : However when I replace POSIXct by POSIXlt it breaks (this looks like a : bug to me): : : as.POSIXlt(2000-05-10 10:15:00, tz=PST8PDT) - : as.POSIXlt(2000-05-10 10:15:00, tz=GMT) : Time difference of 0 secs : : No, it's not a bug. POSIXlt times are just numeric representations of : broken-down times, and the tzone attribute (which is normally not present) : is just a reminder to you. (It has not been checked, so this is avoid : nasty surprises if it is wrong.) Maybe it was a bad idea to allow - for : POSIXlt times, but then we do expect users to read the documentation : (including the code if they are puzzled). This this is by design then its a bug by virtue of being a design error. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] time zones in POSIXt
On Fri, Apr 23, 2004 at 11:30:19AM -0700, Vadim Ogranovich wrote: Hi, I have two data sources. One records time in PST time zone, the other in GMT. I want to compute the difference between the two, but don't see how. Here is an example where I compute time difference between identical times each (meant to be) relative to its time zone. as.POSIXlt(2000-05-10 10:15:00, PST) - as.POSIXlt(2000-05-10 10:15:00, GMT) Time difference of 0 secs I was expecting to see 8hrs (which is the time difference between London and San-Francisco). Why is it so and what is the correct way of doing it? Seems to work with POSIXct in 1.8.1 and 1.9.0: as.POSIXct(2000-05-10 10:15:00, PST8PDT) - as.POSIXct(2000-05-10 10:15:00, tz=UTC) Time difference of 7 hours Dirk I use R-1.8.1 on RH-7.3. Thanks, Vadim [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- The relationship between the computed price and reality is as yet unknown. -- From the pac(8) manual page __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] time zones in POSIXt
Thank you for the lead, Dirk! Indeed this works on my machine too: as.POSIXct(2000-05-10 10:15:00, tz=PST8PDT) - as.POSIXct(2000-05-10 10:15:00, tz=GMT) Time difference of 7 hours However when I replace POSIXct by POSIXlt it breaks (this looks like a bug to me): as.POSIXlt(2000-05-10 10:15:00, tz=PST8PDT) - as.POSIXlt(2000-05-10 10:15:00, tz=GMT) Time difference of 0 secs Now a couple of new questions: * how could I learn about appropriate names for time zones? For example I was using PST whereas it seems I had to use either PST8 or PST8PDT. Why PST was not good? Is it documented anywhere? * there seems to be no difference betweeen GMT and BST on my machine though PST8 and PST8PDT are treated properly: # PST8 is not identical to PST8PDT ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz=PST8) - ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz=PST8PDT) Time differences of0,0,0,0, 3600, 3600, 3600, 3600, 3600, 3600,0,0 secs # GMT0 is identical to BST ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz=GMT0) - ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz=BST) Time differences of 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 secs Why is such dichotomy? Thanks, Vadim -Original Message- From: Dirk Eddelbuettel [mailto:[EMAIL PROTECTED] Sent: Friday, April 23, 2004 1:52 PM To: Vadim Ogranovich Cc: R-Help Subject: Re: [R] time zones in POSIXt On Fri, Apr 23, 2004 at 11:30:19AM -0700, Vadim Ogranovich wrote: Hi, I have two data sources. One records time in PST time zone, the other in GMT. I want to compute the difference between the two, but don't see how. Here is an example where I compute time difference between identical times each (meant to be) relative to its time zone. as.POSIXlt(2000-05-10 10:15:00, PST) - as.POSIXlt(2000-05-10 10:15:00, GMT) Time difference of 0 secs I was expecting to see 8hrs (which is the time difference between London and San-Francisco). Why is it so and what is the correct way of doing it? Seems to work with POSIXct in 1.8.1 and 1.9.0: as.POSIXct(2000-05-10 10:15:00, PST8PDT) - as.POSIXct(2000-05-10 10:15:00, tz=UTC) Time difference of 7 hours Dirk I use R-1.8.1 on RH-7.3. Thanks, Vadim [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- The relationship between the computed price and reality is as yet unknown. -- From the pac(8) manual page __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html