Just noticed something else so editing this...
The are different, as @mara says, because their classes are very different
x <- lubridate::hms(c("09:10:01", "09:10:02", "09:10:03"))
class(x)
#> [1] "Period"
#> attr(,"package")
#> [1] "lubridate"
y <- lubridate::mdy_hms(c("09:10:01", "09:10:02", "09:10:03"))
#> Warning: All formats failed to parse. No formats found.
class(y)
#> [1] "POSIXct" "POSIXt"
There is an issue on git that seems to be vaguely related to this:
which has been combined with another similar issue.
I dug into the code a tiny bit and couldn't see where tibble discriminates between a POSIX time and a Period class. There are a lot of places in tibble that seem to strip away the class before processing.
There is a comment in the doc's about what tibble will accept:
#' # data frames can only contain 1d atomic vectors and lists
#' # and can not contain POSIXlt
x, the instance of a Period class, has mulitple slots in it but a POSIX time does not:
x <- lubridate::hms(c("09:10:01", "09:10:02", "09:10:03"))
str(x)
#> Formal class 'Period' [package "lubridate"] with 6 slots
#> ..@ .Data : num [1:3] 1 2 3
#> ..@ year : num [1:3] 0 0 0
#> ..@ month : num [1:3] 0 0 0
#> ..@ day : num [1:3] 0 0 0
#> ..@ hour : num [1:3] 9 9 9
#> ..@ minute: num [1:3] 10 10 10
y <- lubridate::mdy_hms(c("09:10:01", "09:10:02", "09:10:03"))
#> Warning: All formats failed to parse. No formats found.
str(y)
#> POSIXct[1:3], format: NA NA NA
Maybe that is why x is rejected?
Maybe it is a oversight in the implementation since there are parts of the impl that strips away the class of the input before processing. Might be worth posting an issue on git?
y, the POSIX time is not a 1d vector but that case is specially excepted in the doc's as long as it is not a POSXlt