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

Zero Range for HMS object #468

Open
muschellij2 opened this issue Oct 11, 2024 · 0 comments · May be fixed by #469
Open

Zero Range for HMS object #468

muschellij2 opened this issue Oct 11, 2024 · 0 comments · May be fixed by #469

Comments

@muschellij2
Copy link

The use case for this bug is at tidyverse/ggplot2#6134

The zero_range internal function has different behavior for hms and all difftime objects if there is a "midnight" in there aka 00:00:00 hms value.

Simple Example

Let's say a function calculated a range of hms objects and midnight not in there:

range = structure(c(1234, 7380), class = "difftime", units = "secs")
scales:::zero_range(range)
#> Error in `/.difftime`((x[1] - x[2]), m): second argument of / cannot be a "difftime" object

The error happens at

abs((x[1] - x[2]) / m) < tol
and m in this case is a difftime object.

Create a sequence that crosses midnight, range has a 0 in there, so no error.
The error is “resolved” because

if (m == 0) {
exits with FALSE.

range_with_zero = structure(c(0, 7380), class = "difftime", units = "secs")
scales:::zero_range(range_with_zero)
#> [1] FALSE
@teunbrand teunbrand linked a pull request Oct 11, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant