-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent Parsing of Midnight-Time Component in lubridate::ymd_hms()? #1124
Comments
I have run into this issue too and I came here to ask the same question. Due to the edge case of dropping the However, I have tracked down the source of this issue and it turns out it comes from a call to the base R function Line 745 in 11d1c9a
For example:
I think this demonstrates that lubridate is being consistent with base R. It is just a property of how the |
I just wanted to ping this issue to say that this behavior persists (perhaps unsurprisingly since it is a result of base R's treatment of this class). |
Just wanting to ping this again, as it can cause issues down stream, particularly if the users happens to call
Thus leading to a loss of the data. Does mean one has to be very careful when munging date data. |
Yup. Got hit by this one also. Maybe a warning in the docs could help? One would expect the default behavior of ymd_hms("1980-01-01 00:00:00") to yield a date time object, but it gives a date instead. It is a common use case. For example, if you want to write a test with testthat, your fixtures would be hardcoded date times and its natural for the developer to go for basic 00:00:00 for a test. My unrequested 0.02. Best wishes. |
I am not sure why the original poster is passing POSIXct objects to However, "2024-01-01 00:00:00" |> lubridate::ymd_hms() |> as.character()
# [1] "2024-01-01"
"2024-01-01 00:00:00" |> as.POSIXct(tz='UTC') |> as.character()
# [1] "2024-01-01"
``
In my experience, the time component of the timestamp is dropped when exporting a data frame with `write.csv()` which is the first place I ran into this (when publishing data to [EDI](https://edirepository.org/)). However, note that using `format` to convert to character before export is probably the best workaround.
```R
"2024-01-01 00:00:00" |> lubridate::ymd_hms() |> format("%Y-%m-%d %H:%M:%S")
# [1] "2024-01-01 00:00:00" |
Dear maintainers,
I'm not sure it's a proper issue considering it happens when parsing from a Posicx (I know it's not what the function is for), but the way the
ymd_hms
function handles the00:00:00
time seems inconsistent (?)The workaround I found is to convert the Posicx into a character, while being explicit about the time:
SeesionInfo
The text was updated successfully, but these errors were encountered: