tidyverse / lubridate

Make working with dates in R just that little bit easier
https://lubridate.tidyverse.org
GNU General Public License v3.0
724 stars 207 forks source link

round_date in 0.1 sec doesn't work correctly #1152

Open EdsterShih opened 7 months ago

EdsterShih commented 7 months ago

Here is an example

library(magrittr) library(lubridate)

Correctly work

as.POSIXct("2024-01-08 14:09:59.899") %>% round_date(., unit="0.1 sec") %>% as.character as.POSIXct("2024-01-08 14:09:59.999") %>% round_date(., unit="1 sec") %>% as.character

Not work as I think

as.POSIXct("2024-01-08 14:09:59.999") %>% round_date(., unit="0.1 sec") %>% as.character

the result I think: 2024-01-08 14:10:00.0 the result shows: 2024-01-08 14:09:59.9