Roland Fu?
on Tue, 20 Sep 2022 09:25:52 +0200 writes:
Hello, May I follow up on this? Has it fallen through the
cracks or were there considerations against passing `tz`
to `.POSIXct`?
Hmm... I don't remember even though I had replied positively
to your question in May 2018.
PROS (for allowing 'tz') to be passed to
---- as.POSIXct.Date() and hence ideally also to as.POSIXlt.Date()
1) as.POSIXct() and as.POSIXlt() all show with a 'tz' argument
on the help page, and hence for consistency users should
really expect that 'tz = ".."' also works in these two cases:
as.POSIXct(x, tz = "", ...)
as.POSIXlt(x, tz = "", ...)
## S3 method for class 'character'
as.POSIXlt(x, tz = "", format,
tryFormats = c("%Y-%m-%d %H:%M:%OS",
"%Y/%m/%d %H:%M:%OS",
"%Y-%m-%d %H:%M",
"%Y/%m/%d %H:%M",
"%Y-%m-%d",
"%Y/%m/%d"),
optional = FALSE, ...)
## Default S3 method:
as.POSIXlt(x, tz = "",
optional = FALSE, ...)
## S3 method for class 'numeric'
as.POSIXlt(x, tz = "", origin, ...)
2) It is easy to be implemented for as.POSIXct() as you found
already in 2018.
3) The 'Details:' section on the help page,
end of 1st paragraph says
Dates without times are treated as being at midnight UTC.
So the current hardwired behavior is documented.
4a) For as.POSIXlt.Date() to allow passing 'tz' needs changes
in the C code, i.e., is considerable more work than for the as.POSIXct(),
(or actually just post-processing in the R code, much less work)
4b) Only changing the behavior for as.POSIXct() but not for as.POSIXlt()
is also an inconsistency.
My personal inclination would still be to do the change,
by giving most weight to '1)' above.
What do other experienced R developers think ?
Am 17.05.2018 um 19:55 schrieb Martin Maechler:
Roland Fu? on Wed, 16 May 2018 17:21:07 +0200
writes:
R 3.5.0 Is it intended that the Date method of
as.POSIXct > does not respect the tz parameter? I suggest
changing > as.POSIXct.Date
which is
function (x, ...) .POSIXct(unclass(x) * 86400)
function (x, tz = "", ...) .POSIXct(unclass(x) * 86400,
tz = tz)
or rather just forward the '...', i.e., use
function (x, ...) .POSIXct(unclass(x) * 86400, ...)
??
Currently, the best workaround seems to be using the >
character method if one doesn't want the default timezone
(which is often an annoying DST timezone).
This came up on Stack Overflow: >
Thank you Roland for your notice (and the help on SO).
Best, Martin
Th?nen-Institut f?r Agrarklimaschutz/ Th?nen Institute of
Climate-Smart Agriculture
Bundesallee 65 D-38116 Braunschweig, Germany
Tel.: ++49 531 596 2627 Fax: ++49 531 596 2699 Email:
roland.fuss at thuenen.de
Arbeitsgruppe "Emissionsberichterstattung"/ Working group
"Emission Inventories" Email:
emissionsinventare at thuenen.de
Das Johann Heinrich von Th?nen-Institut,
Bundesforschungsinstitut f?r L?ndliche R?ume, Wald und
Fischerei ? kurz: Th?nen-Institut ? besteht aus 15
Fachinstituten, die in den Bereichen ?konomie, ?kologie
und Technologie forschen und die Politik beraten.
The Johann Heinrich von Th?nen Institute, Federal Research
Institute for Rural Areas, Forestry and Fisheries ? Th?nen
Institute in brief ? consists of 15 specialized institutes
that carry out research and provide policy advice in the
fields of economy, ecology and technology.