Closed qgeissmann closed 3 years ago
Agreed that we should be able to round-trip correctly.
@hadley: Should as.hms.character()
give a warning if it cannot parse its arguments, perhaps optionally?
I think you should follow the convention of readr (and base R), which, IIRC, is to warn whenever there is a failure. It'd be more work, but it's probably worth it, to return a problems data frame as an attribute like in readr, as that way you can also use stop_for_problems()
.
Thanks, I will study how it is implemented in readr
and follow the convention before I submit a PR
The parser here is very simple, sophisticated parsing is outside the scope of this package.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
as.hms("12:00") = NA
-10:21:00
could be parsed as wellas.hms("-12:00:01") = NA
Dd
,DdHH:MM
, orDdHH:MM:SS
(especially if we make adhms
class, see #12). Decimal number of days should only be allowed when no hour is provides (e.g. "0.5d12:00:11" does not make sense).as.hms("24:00:01") = NA
. This is unexpected since we displayhms(86401)
as "24:00:01".as.hms("21:00:0012ABC")
is "21:00:12".as.hms("21:1:00")
is "21:01:12".NA
without always knowing why. For instanceas.hms("21:61:00")
andas.hms("hello")
both giveNA
, and no warning/error.I attempted a prototypical parser that addresses these issues (https://github.com/qgeissmann/dhms). I am happy to work on it and merge it.