[R] order list of date (bug?)

William Dunlap wdunlap at tibco.com
Sat Jan 21 06:10:36 CET 2017


When did the switch between 'summer time'/'winter time' (or 'daylight
savings'/'standard') happen in CET last year?  (Did 2:35 exist on
March 27, 2016?)

At the R level, what is
  as.numeric(strptime(df$DateTime, format='%Y-%m-%d %H:%M:%S'))
with your time zone settings?
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Thu, Jan 19, 2017 at 11:18 AM, rob vech <rob.vech87 at gmail.com> wrote:
> Hi list,
> I'd like to submit the following problem that seems a bug but it is so
> strange that it could be my mind ... so
> I would like to sort a list of date time items like in this script:
>
> df = data.frame(DateTime = c(
> '2016-12-21 10:34:54',
> '2016-12-21 11:04:54',
> '2016-12-21 11:34:54',
> '2016-03-27 02:05:50',
> '2016-03-27 02:35:50',
> '2016-12-21 12:04:54',
> '2016-12-21 12:34:54'
> ))
>
> df$DateTime = as.POSIXlt(strptime(df$DateTime, format='%Y-%m-%d %H:%M:%S'))
>
> ord = order(as.numeric(strptime(df$DateTime, format='%Y-%m-%d %H:%M:%S')))
>
> df.ord = df[ord,1]
> df.ord
>
> I have the following results:
>
> "2016-12-21 10:34:54 CET"
> "2016-12-21 11:04:54 CET"
> "2016-12-21 11:34:54 CET"
> "2016-12-21 12:04:54 CET"
> "2016-12-21 12:34:54 CET"
> "2016-03-27 02:05:50"
> "2016-03-27 02:35:50"
>
> the last two terms should be before (note that CET is missing).
>
> if I change "2016-03-27 02:05:50" and "2016-03-27 02:35:50" to something
> like "2016-03-27 01:05:50" and "2016-03-27 01:35:50"
> it seems to work. It seems to have problem with 02 hours. Any ideas?
> I'm using R-3.1.2 on Win
> Thank you
> rob
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list