Excellent! Thanks a lot. Solution general enough, simple and
understandable. Will try and stick on it...
Should be nice to add this simple and clear example to the as.POSIXxx
documentation.
Thanks again,
Patrick
jim holtman a écrit :> forgot, in your case it should be:
>
> tz="chs-8chd"
>
> > (x <- as.POSIXct(mydate, tz='chs-8chd'))
> [1] "2006-05-16 11:30:00 chd"
> > format(x, tz="GMT")
> [1] "2006-05-16 02:30:00"
> >
>
>
>
> On 5/21/06, *Patrick Giraudoux* <patrick.giraudoux@univ-fcomte.fr
> <mailto:patrick.giraudoux@univ-fcomte.fr>> wrote:
>
> Dear Listers,
>
> Apologize to pile up on the 'tz' issue in POSIX objects. I have
a
> 'simple' thing on which I must make up my mind but cannot do it
> from the
> existing R-help threads. I am currently working on dog telemetry in
> China, and download time information from GPS collars. I would like to
> set up the corresponding POSIXxx variables in R to a given time
> zone. Eg
> Pekin GMT+8:00.
>
> I cannot find out how to do it properly. For instance:
>
> mydate<-""06/05/16/11:30:00""
> mydate<-strptime(mydate, "%y/%m/%d/%H:%M:%S")
>
> mydate
> [1] "2006-05-16 11:30:00"
> as.POSIXct(mydate)
> [1] "2006-05-16 11:30:00 Paris, Madrid"
>
> Which is obviously not what I wish regarding the specification Paris,
> Madrid...
>
> I have tried to pass something to the argument tz
>
> mydate2<-strptime(mydate,
"%y/%m/%d/%H:%M:%S",tz="GMT") or
> mydate2<-strptime(mydate,
"%y/%m/%d/%H:%M:%S",tz="GMT+08")
>
> I get this:
>
> mydate2
> [1] NA
>
> Is there a way to specify the time zone on which I was working
> (actually
> GTM + 8:00)? I have read in R-help that this is system dependent, but
> the how to do it still escape. Working with Windows, I have
> checked the
> following address given by Gabor Grothendieck in R-help,
> http://msdn2.microsoft.com/en-us/library/90s5c885.aspx, but I cannot
> manage with the syntax: *TZ*=tzn[+ | –]hh[*:*mm[*:*ss] ][dzn]. They
> mention a three lettre time zone (where can the corresponding codes be
> found?) to which to add a difference in hours between UTC and the
> local
> time... but any trial I did specifying tz="UTM+08" or other
> combination
> leads nowhere...
>
> Thanks for any hint...
>
> Patrick
>
> ______________________________________________
> R-help@stat.math.ethz.ch <mailto:R-help@stat.math.ethz.ch>
mailing
> list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390 (Cell)
> +1 513 247 0281 (Home)
>
> What is the problem you are trying to solve?
[[alternative HTML version deleted]]