Jeff Newmiller
2021-Apr-29 21:19 UTC
[R] Date Time, as.POSIXct used locale, strange plot behavior
What is your TZ environment variable set to? That's what time conversion defaults to ?DateTimeClasses Also, I am not sure CEST is a valid timezone designation... it can be system dependent, but using one of the elements listed in ?OlsonNames. On April 29, 2021 12:22:44 PM PDT, Tilmann Faul <Tilmann_Faul at t-online.de> wrote:>Hy, > >stumbled over the following problem while plotting DateTime Objects. > >plot(as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21 23:59:59")), c(0, >1), type='l') > >arrows(as.POSIXct("2021-04-21 00:00:00", tz="CEST"), > 0.3, > as.POSIXct("2021-04-21 00:00:00", tz="CEST"), > 0.2, > length=0.07, angle=15) > ># arrow at 02:00, why? > >arrows(as.POSIXct("2021-04-21 00:00:00"), > 0.3, > as.POSIXct("2021-04-21 00:00:00"), > 0.2, > length=0.07, angle=15, col='red') > ># arrow at 00:00 as expected > >as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21 23:59:59"))[1] ># [1] "2021-04-21 CEST" >as.POSIXct("2021-04-21 00:00:00", tz="CEST") ># [1] "2021-04-21 CEST" >as.POSIXct("2021-04-21 00:00:00") ># [1] "2021-04-21 CEST" > >all representations on my system are the same, why is the plot location >of the arrows different?? >I am located in Germany, my locale: >Sys.getlocale() >[1] >"LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=de_DE.UTF-8;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE.UTF-8;LC_IDENTIFICATION=C" > >Any Idea? > >Best regards >Tilmann > >______________________________________________ >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.-- Sent from my phone. Please excuse my brevity.
PIKAL Petr
2021-Apr-30 07:04 UTC
[R] Date Time, as.POSIXct used locale, strange plot behavior
Hi.
It should be probably CET not CEST.
arrows(as.POSIXct("2021-04-21 00:00:00", tz="CEST"),
0.3,
as.POSIXct("2021-04-21 00:00:00", tz="CEST"),
0.2,
length=0.07, angle=15)
arrows(as.POSIXct("2021-04-21 00:00:00", tz="CET"),
0.3,
as.POSIXct("2021-04-21 00:00:00", tz="CET"),
0.2,
length=0.07, angle=15)
Cheers
Petr
> -----Original Message-----
> From: R-help <r-help-bounces at r-project.org> On Behalf Of Jeff
Newmiller
> Sent: Thursday, April 29, 2021 11:20 PM
> To: r-help at r-project.org; Tilmann Faul <Tilmann_Faul at
t-online.de>
> Subject: Re: [R] Date Time, as.POSIXct used locale, strange plot behavior
>
> What is your TZ environment variable set to? That's what time
conversion
> defaults to ?DateTimeClasses
>
> Also, I am not sure CEST is a valid timezone designation... it can be
system> dependent, but using one of the elements listed in ?OlsonNames.
>
> On April 29, 2021 12:22:44 PM PDT, Tilmann Faul <Tilmann_Faul at
t-online.de>
> wrote:
> >Hy,
> >
> >stumbled over the following problem while plotting DateTime Objects.
> >
> >plot(as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21
23:59:59")), c(0,
> >1), type='l')
> >
> >arrows(as.POSIXct("2021-04-21 00:00:00",
tz="CEST"),
> > 0.3,
> > as.POSIXct("2021-04-21 00:00:00",
tz="CEST"),
> > 0.2,
> > length=0.07, angle=15)
> >
> ># arrow at 02:00, why?
> >
> >arrows(as.POSIXct("2021-04-21 00:00:00"),
> > 0.3,
> > as.POSIXct("2021-04-21 00:00:00"),
> > 0.2,
> > length=0.07, angle=15, col='red')
> >
> ># arrow at 00:00 as expected
> >
> >as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21
23:59:59"))[1] # [1]
> >"2021-04-21 CEST"
> >as.POSIXct("2021-04-21 00:00:00", tz="CEST") # [1]
"2021-04-21 CEST"
> >as.POSIXct("2021-04-21 00:00:00")
> ># [1] "2021-04-21 CEST"
> >
> >all representations on my system are the same, why is the plot location
> >of the arrows different??
> >I am located in Germany, my locale:
> >Sys.getlocale()
> >[1]
> >"LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-
> 8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=de_DE.UTF-
> 8;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-
> 8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_D
> E.UTF-8;LC_IDENTIFICATION=C"
> >
> >Any Idea?
> >
> >Best regards
> >Tilmann
> >
> >______________________________________________
> >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.
>
> --
> Sent from my phone. Please excuse my brevity.
>
> ______________________________________________
> 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.
Tilmann Faul
2021-Apr-30 07:50 UTC
[R] Date Time, as.POSIXct used locale, strange plot behavior
Dear Jeff,
Thanks for your answer.
Sys.timezone() gives
[1] "Europe/Berlin"
I tried "Europe/Berlin" as tz argument, giving the same result als
using
"CEST" (Central European Summer Time).
It seems to me, that using as.POSIXct without tz argument defaults to tz
UTC and with tz argument, either "CEST" or "Europ/Berlin"
uses the
European tz, regarding the plot.
Never the less i do not understand why all of them have the same time
printout on my system.
as.POSIXct("2021-04-21 00:00:00", tz="CEST")
# [1] "2021-04-21 CEST"
as.POSIXct("2021-04-21 00:00:00", tz="Europ/Berlin")
# [1] "2021-04-21 Europ"
as.POSIXct("2021-04-21 00:00:00")
# [1] "2021-04-21 CEST"
Can someone comment on that, please?
best Regards
Tilmann
On 29.04.21 23:19, Jeff Newmiller wrote:> What is your TZ environment variable set to? That's what time
conversion defaults to ?DateTimeClasses
>
> Also, I am not sure CEST is a valid timezone designation... it can be
system dependent, but using one of the elements listed in ?OlsonNames.
>
> On April 29, 2021 12:22:44 PM PDT, Tilmann Faul <Tilmann_Faul at
t-online.de> wrote:
>> Hy,
>>
>> stumbled over the following problem while plotting DateTime Objects.
>>
>> plot(as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21
23:59:59")), c(0,
>> 1), type='l')
>>
>> arrows(as.POSIXct("2021-04-21 00:00:00",
tz="CEST"),
>> 0.3,
>> as.POSIXct("2021-04-21 00:00:00", tz="CEST"),
>> 0.2,
>> length=0.07, angle=15)
>>
>> # arrow at 02:00, why?
>>
>> arrows(as.POSIXct("2021-04-21 00:00:00"),
>> 0.3,
>> as.POSIXct("2021-04-21 00:00:00"),
>> 0.2,
>> length=0.07, angle=15, col='red')
>>
>> # arrow at 00:00 as expected
>>
>> as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21
23:59:59"))[1]
>> # [1] "2021-04-21 CEST"
>> as.POSIXct("2021-04-21 00:00:00", tz="CEST")
>> # [1] "2021-04-21 CEST"
>> as.POSIXct("2021-04-21 00:00:00")
>> # [1] "2021-04-21 CEST"
>>
>> all representations on my system are the same, why is the plot location
>> of the arrows different??
>> I am located in Germany, my locale:
>> Sys.getlocale()
>> [1]
>>
"LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=de_DE.UTF-8;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE.UTF-8;LC_IDENTIFICATION=C"
>>
>> Any Idea?
>>
>> Best regards
>> Tilmann
>>
>> ______________________________________________
>> 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.
>