[STATSGRASS] Raster time series and R - timezones?

Roger Bivand Roger.Bivand at nhh.no
Wed Jun 21 04:04:28 EDT 2006


On Wed, 21 Jun 2006, Hamish wrote:

> Markus wrote:
> 
> > > > > strptime(mytime,"%d %b %Y %H:%M:%S")
> > > > [1] "2006-04-07 10:30:00"
> > > > -> UTC lost
> > > 
> > > add %Z to include timezone?
> > 
> > This is the lacking feature... strptime doesn't care of %Z.
> 
> 
> Then it's R's strptime() which has a problem. 
> 
> I found %Z on the glibc <time.h> strptime() help page.
> 
> Maybe it is best to write a little bash script using `date --iso` or
> tiny C program using time.h's strptime() to pre-process the data?
> I take it R lets you do system() calls somehow.
> versus fighting R for a feature which doesn't exist.
> 
> does R have a gmtime() or localtime() equivalent?
> 

The problems seem to stem from R trying to work cross-platform and 
cross-locale. The help page for strptime() does say that %Z and %z are 
output only. It is an interaction of platform (and platform libraries) and 
the way locales are represented on that platform and the locale affecting 
the R process. There have been threads a number of times on this, also 
because locales affect i18n etc. Maybe it is time to draft a short message 
to R-help:

Sys.getlocale()
sessionInfo()
mytime <- "7 May 2006 10:30:00 UTC"
t0 <- strptime(mytime,"%d %b %Y %H:%M:%S")
# how to get mytime into ISOdatetime() ?
t1 <- ISOdatetime(t0$year+1900, t0$mon+1, t0$mday, t0$hour, t0$min, 
  t0$sec, tz="UTC")
t1
attributes(t1)

Are we getting anywhere??

Roger

> 
> Hamish
> 
> _______________________________________________
> statsgrass mailing list
> statsgrass at grass.itc.it
> http://grass.itc.it/mailman/listinfo/statsgrass
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no





More information about the grass-stats mailing list