Re: [R] POSIXlt and daylight savings time
pdb wrote: >> as.POSIXlt('2004-10-31 02:00:00') > [1] "2004-10-31" >> as.POSIXlt('2004-10-31 03:00:00') > [1] "2004-10-31 03:00:00" > > How do I tell as.POSIXlt() to ignore daylight savings and just convert to > a time as is? I've read about the 'isdst' but it is still unclear what to > do. There *was* no 02:00:00 in your local timezone, so you’re trying to specifiy a point in time that just didn’t exist. If you really want to do this, use the UTC timezone, by setting the ‘tz’ argument in as.POSIXct/as.POSIXlt to UTC (or GMT). -- Karl Ove Hufthammer E-mail: k...@huftis.org Jabber: huf...@jabber.no __ 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.
Re: [R] POSIXlt and daylight savings time
Hello, Jeff already answered to your question, as.POSIXlt('2004-10-31 02:00:00', format = "%Y-%m-%d %H:%M:%S") And in my system and timezone (GMT) I get as.POSIXlt('2004-10-31 02:00:00') [1] "2004-10-31 02:00:00" So Jeff's point (b) should also be followed. sessionInfo() R version 2.15.1 (2012-06-22) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252 [3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C [5] LC_TIME=Portuguese_Portugal.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] fortunes_1.4-2 tools_2.15.1 Hope this helps, Rui Barradas Em 05-09-2012 09:24, pdb escreveu: I'll rephrase the question... If you try... as.POSIXlt('2004-10-31 02:00:00') you get [1] "2004-10-31" What do I need to do to make it return [1] "2004-10-31 02:00:00" -- View this message in context: http://r.789695.n4.nabble.com/POSIXlt-and-daylight-savings-time-tp4642253p4642272.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] POSIXlt and daylight savings time
I'll rephrase the question... If you try... as.POSIXlt('2004-10-31 02:00:00') you get [1] "2004-10-31" What do I need to do to make it return [1] "2004-10-31 02:00:00" -- View this message in context: http://r.789695.n4.nabble.com/POSIXlt-and-daylight-savings-time-tp4642253p4642272.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] POSIXlt and daylight savings time
a) Don't use POSIXlt in data frames... use POSIXct. POSIXlt is like a data frame of its own, and data frames within data frames lead to surprising results, to say the least. b) I have had best luck using Sys.setenv( TZ="Etc/GMT+8" ) for US Pacific Standard Time as "local" time for the duration of analysis. c) Use the format argument if you want consistent results. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. pdb wrote: >I have a data frame that contains dates, but when I use as.POSIXlt() I >lose >the hours on all records. I traced this down to a particuar hour which >causes the issue... > >> as.POSIXlt('2004-10-31 02:00:00') >[1] "2004-10-31" >> as.POSIXlt('2004-10-31 03:00:00') >[1] "2004-10-31 03:00:00" > >How do I tell as.POSIXlt() to ignore daylight savings and just convert >to a >time as is? I've read about the 'isdst' but it is still unclear what to >do. > >This is a cleaned up date field that I received so adjusting the date >itself >is not possible. > >Thanks in advance. > > > >-- >View this message in context: >http://r.789695.n4.nabble.com/POSIXlt-and-daylight-savings-time-tp4642253.html >Sent from the R help mailing list archive at Nabble.com. > >__ >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] POSIXlt and daylight savings time
I have a data frame that contains dates, but when I use as.POSIXlt() I lose the hours on all records. I traced this down to a particuar hour which causes the issue... > as.POSIXlt('2004-10-31 02:00:00') [1] "2004-10-31" > as.POSIXlt('2004-10-31 03:00:00') [1] "2004-10-31 03:00:00" How do I tell as.POSIXlt() to ignore daylight savings and just convert to a time as is? I've read about the 'isdst' but it is still unclear what to do. This is a cleaned up date field that I received so adjusting the date itself is not possible. Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/POSIXlt-and-daylight-savings-time-tp4642253.html Sent from the R help mailing list archive at Nabble.com. __ 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.