[R] timezones
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Aug 4 08:50:10 CEST 2003
The solution to all these problems is to use UTC. You can't select a
`standard time' such as EST: that does not exist for half the year.
The only `timezone' without DST that we can guarantee to be available is
UTC.
You seem to have misunderstandings about how to set (not convert to) UTC.
On Thu, 31 Jul 2003, Jerome Asselin wrote:
>
> I share your concerns regarding Problems 1 and 2. However, I am unable to
> provide help on those at this moment.
>
> As for Problem 3, an alternative for the time being would be to use
> another package such as chron or date, although it would be preferable to
> use the classes of the base package if possible.
>
> Sorry I can't be more helpful.
>
> Jerome
>
> On July 30, 2003 09:19 pm, Gabor Grothendieck wrote:
> > 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"))
That does not convert to GMT: that gives you a list representation in 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.
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
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
More information about the R-help
mailing list