I have some questions and comments on timezones.

Problem 1.

# get current time in current time zone
> (now <- Sys.time())
[1] "2003-07-29 18:23:58 Eastern Daylight Time"

# convert this to GMT
> (now.gmt <- as.POSIXlt(now,tz="GMT"))
[1] "2003-07-29 22:23:58 GMT"

# take difference
> now-now.gmt
Time difference of -5 hours

Note that the difference between the times displayed by the first two
R expressions is -4 hours.  Why does the last expression return
-5 hours?


Problem 2.  Why do the two expressions below give different answers?
I take the difference between two dates in GMT and then repeat it in the current time 
zone (EDT).

# days since origin in GMT
> julian(as.POSIXct("2003-06-29",tz="GMT"),origin=as.POSIXct("1899-12-30",tz="GMT"))
Time difference of 37801 days

# days since origin in current timezone
> julian(as.POSIXct("2003-06-29"),origin=as.POSIXct("1899-12-30"))
Time difference of 37800.96 days


I thought this might be daylight savings time related but even with 
standard time I get:

> julian(as.POSIXct("2003-06-29",tz="EST"),origin=as.POSIXct("1899-12-30",tz="EST"))
Time difference of 37800.96 days


Problem 3. What is the general strategy of dealing with dates, as 
opposed to datetimes, in R?  

I have had so many problems and a great deal of frustration, mostly 
related to timezones.

The basic problem is that various aspects of the date such as the year, 
the month, the day of the month, the day of the week can be different 
depending on the timezone you use.  This is highly undesirable since 
I am not dealing with anything more granular than a day yet timezones, 
which are completely extraneous to dates and by all rights should not 
have to enter into my problems, keep fowling me up.   

A lesser problem is that I find myself using irrelevant constants such 
as the number of seconds in a day which you would think would be something I would not 
have to deal with since I am concerned with daily 
data.

With R have nifty object oriented features I think a good project would
be to implement a class in the base that handled dates without times 
(or timezones!)

P.S. I have sent an earlier version of this but did not see it posted 
so if both get posted please ignore the prior one since this one has more info in it.

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to