On 21/09/2014 14:11, Denis Chabot wrote:> Hi,
>
> I have to deal with time-stamped data coming from outside my own time zone,
so the problem is likely poor knowledge of European time zones on my part. But I
am puzzled just the same.
>
> I thought that setting a time zone of "Europe/Copenhagen" would
be the same as "CET" in winter and "CEST" in summer.
You thought wrong: CEST is not a valid timezone on most (maybe all) R
platforms.
You failed to tell us the 'at a minimum' information required by the
posting guide. ?Sys.timezone says OlsonNames() tells you the timezone
names supported on your unstated platform, and ?as.POSIXct says
tz: A time zone specification to be used for the conversion, _if
one is required_. System-specific (see time zones), but
?""?
is the current time zone, and ?"GMT"? is UTC (Universal
Time,
Coordinated). Invalid values are most commonly treated as
UTC, on some platforms with a warning.
As the posting guide asks, please do your own homework.
> This test in winter works as expected:
>
>> a = as.POSIXct("2013-02-25 01:00:00",
tz="Europe/Copenhagen"); a
> [1] "2013-02-25 01:00:00 CET"
>> b = as.POSIXct("2013-02-25 01:00:00", tz="CET"); b
> [1] "2013-02-25 01:00:00 CET"
>> a-b
> Time difference of 0 secs
>
> But this one is summer does not work as I expected:
>
>> c = as.POSIXct("2013-07-25 01:00:00",
tz="Europe/Copenhagen"); c
> [1] "2013-07-25 01:00:00 CEST"
>> d = as.POSIXct("2013-07-25 01:00:00", tz="CEST"); d
> [1] "2013-07-25 01:00:00 UTC"
>> e = as.POSIXct("2013-07-25 01:00:00", tz="CET"); e
> [1] "2013-07-25 01:00:00 CEST"
>> c-d
> Time difference of -2 hours
>> c-e
> Time difference of 0 secs
>
> Setting tz to "Europe/Copenhagen" in summer in c first appears to
be the same as setting it to "CEST" because the output is showing
"CEST".
>
> But d should then be the same as c, and it is not.
>
> What is happening?
>
> Thanks in advance,
>
> Denis Chabot
>
> ______________________________________________
> R-help at 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.
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK