Skip to content
Prev 62205 / 63421 Next

round.Date and trunc.Date not working / implemented

I just wanted to add some additional problems from trying to replicate this.
`trunc` does indeed work as advertised here, as does calling `round.POSIXt(Sys.Date())`
and `round(Sys.Date())`. These functions are definitely implemented.

However, I am also able to replicate Ji???s error:

```
[1] "2024-02-08"
[1] "2024-01-01 EST"
Error in round.default(19761, "years") :
  non-numeric argument to mathematical function
```

Specifying `units="years"` causes errors ? either an error from named argument
(`unused argument units="years"`) or the above error when the argument is unnamed.
The error they?re experiencing isn?t actually from `round.Date`, it?s from trying
to call `round("years")`, which is done implicitly when `"years"` is provided as an
unnamed second argument to `round()`.

I suspect that the original bug report is referencing this behavior. Yes, it is correct
that `round.Date` does not accept a `units` parameter as implemented and as specified in
the help file. However, it does feel a little odd that `round.POSIXt` does accept a `units`
parameter, but `round.Date` does not. Adding that capability would be fairly simple, unless
there are other reasons why it isn?t implemented. Just my quick thoughts.

-Aidan

-----------------------
Aidan Lakshman (he/him)
http://www.ahl27.com/
On 8 Feb 2024, at 9:36, Olivier Benz via R-devel wrote: