HI, Thanks for the information. d1<-ymd_hms("20111231050000") Sys.setenv(TZ="UTC") e2<-c(d1) e2 #[1] "2011-12-31 05:00:00 UTC" Sys.setenv(TZ="EST") e1<-c(d1) attr(e1,"tzone")<-"UTC" e1 #[1] "2011-12-31 05:00:00 UTC"
#Looks similar, attr(e1,"tzone") #[1] "UTC" attr(e2,"tzone") #NULL ?c.POSIXct() Using ‘c’ on ‘"POSIXlt"’ objects converts them to the current time zone, and on ‘"POSIXct"’ objects drops any ‘"tzone"’ attributes (even if they are all marked with the same time zone). So, may be assigning attr(x,"tzone") may be best method A.K. ----- Original Message ----- From: Peter Ehlers <ehl...@ucalgary.ca> To: arun <smartpink...@yahoo.com> Cc: Andre Zege <az...@yahoo.com>; R help <r-help@r-project.org> Sent: Friday, November 16, 2012 11:26 AM Subject: Re: [R] lubridate concatenation issue On 2012-11-16 04:39, arun wrote: > HI, > Sys.setenv(TZ="GMT") > c(d) > #[1] "2011-12-31 GMT" > > #or > Sys.setenv(TZ="UTC") > c(d) > #[1] "2011-12-31 UTC" > > Hope it helps. > A.K. > Yes, but c(d) will still not have a 'tzone' attribute. So the OP is okay as long as his further operations do not depend on the presence of that attribute. Peter Ehlers > > > ----- Original Message ----- > From: Andre Zege <az...@yahoo.com> > To: "r-help@r-project.org" <r-help@r-project.org> > Cc: > Sent: Thursday, November 15, 2012 9:36 PM > Subject: [R] lubridate concatenation issue > > I took a look at Hadley's lubridate which seems a very neat package, but i am > having a small problem with concatenating lubridates to build vectors of it. > Namely when function c( ) is applied to lubridate seems to change time to a > local timezone in this particular case changing the date to previous one. > >> d<-ymd('20111231') >> d > [1] "2011-12-31 UTC" >> c(d) > [1] "2011-12-30 19:00:00 EST" > > > > Is this the expected behavior and if yes, how could it be avoided for this > function and the others that possibly do the same? I mean, i could create the > date in my local timezone and avoid this, but if i don't do it, is there an > option in environment or functions to avoid this from happening -- otherwise > i need to watch out for nasty bugs. > > > Thanks > Andre > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.