[STATSGRASS] Raster time series and R - timezones?

Markus Neteler neteler at itc.it
Wed Jun 21 15:04:29 EDT 2006


On Wed, Jun 21, 2006 at 08:45:13PM +0200, Stephan Holl wrote:
> Hello Markus, 
> 
> On Wed, 21 Jun 2006 18:05:35 +0200 Markus Neteler <neteler at itc.it>
> wrote:
> 
> > Best would be to set R somehow to UTC and to not do anything with
> > daylight saving time since I don't need it.
> 
> export TZ=UTC0
> R
> 
> does this help?

It partially helps: it corrects the behaviour of as.POSIXct()!


> mytime <- "7 May 2006 10:30:00 UTC"
> strptime(mytime,"%d %b %Y %H:%M:%S")
[1] NA					# right, in German locale here
> Sys.setlocale("LC_TIME", "C")
[1] "C"
> strptime(mytime,"%d %b %Y %H:%M:%S")
[1] "2006-05-07 10:30:00"		# OK

> as.POSIXlt(as.POSIXct(strptime(mytime,"%d %b %Y %H:%M:%S")),tz="GMT")
[1] "2006-05-07 10:30:00 GMT"		# OK

> as.POSIXlt(as.POSIXct(strptime(mytime,"%d %b %Y %H:%M:%S"),tz="CEST"))
[1] "2006-05-07 10:30:00 CEST"		# wrong

> as.POSIXlt(as.POSIXct(strptime(mytime,"%d %b %Y %H:%M:%S"),tz="wrong"))
[1] "2006-05-07 10:30:00 wrong"		# write what you want


> as.POSIXlt(as.POSIXct(strptime(mytime,"%d %b %Y %H:%M:%S")),tz="GMT-2")
[1] "2006-05-07 12:30:00 GMT"		# seems to do something


> dt.mytime <- as.POSIXlt(as.POSIXct(strptime(mytime,"%d %b %Y %H:%M:%S")),tz="GMT")
> dt.mytime
[1] "2006-05-07 10:30:00 GMT"		# OK
> dt.mytime[["isdst"]]
[1] 0					# wrong (or not due to LC_TIME=C?)


thanks for the hint,

 markus




More information about the grass-stats mailing list