Skip to content
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

Can hms objects be comapred with strings? #108

Open
yutannihilation opened this issue Jul 2, 2022 · 1 comment
Open

Can hms objects be comapred with strings? #108

yutannihilation opened this issue Jul 2, 2022 · 1 comment

Comments

@yutannihilation
Copy link
Member

I feel the result of the comparison with strings is a bit cryptic...

x <- readr::parse_time(c("19:00:00", "20:00:00", "21:00:00", "30:00:00"))

# why...
x > "20:00:00"
#> [1]  TRUE  TRUE  TRUE FALSE

# expected
x > hms::parse_hms("20:00:00")
#> [1] FALSE FALSE  TRUE  TRUE

Created on 2022-07-02 by the reprex package (v2.0.1)

@zWarMob
Copy link

zWarMob commented Mar 24, 2023

I encountered this today 😅

I expect this comparison to be TRUE

library(hms)

a <- hms(0,0,0); a
#> 00:00:00
b <- "00:00:00"; b
#> [1] "00:00:00"

a == b
#> [1] FALSE

Created on 2023-03-24 with reprex v2.0.2

Specially because R like JS seems to coerce a lot and 3 == '3' is TRUE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants