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

Comparisons between naive times do not account for TimeOfDay value #29

Open
jrstrunk opened this issue May 18, 2024 · 1 comment
Open

Comments

@jrstrunk
Copy link

Thanks for the package, I've gotten lots of use out of it! One thing I noticed is that running this code:

  let assert Ok(t1) = birl.parse("2019-01-01T14:00:00.000-04:00")
  let assert Ok(t2) = birl.parse("2019-01-01T14:00:00.001-04:00")
  birl.compare(t1, t2)
  |> io.debug

will result in Lt, while running this code:

  let assert Ok(t1) = birl.parse("2019-01-01T14:00:00.000")
  let assert Ok(t2) = birl.parse("2019-01-01T14:00:00.001")
  birl.compare(t1, t2)
  |> io.debug

will result in Eq, and this code:

  let assert Ok(t1) = birl.parse("2019-01-01T14:00:00.000")
  let assert Ok(t2) = birl.parse("2019-01-02T14:00:00.001")
  birl.compare(t1, t2)
  |> io.debug

will result in Lt.

It seems to me like the time of day should still be considered when comparing naive times, not just the calendar date.

If you want to preserve the original functionality of only comparing the calendar date, maybe another function should be added like compare_date. I can implement it if the maintainer agrees, any thoughts?

@massivefermion
Copy link
Owner

This is a bug but not in the comparison feature. parse should not accept a string that does not have an offset.
It seems like the parse function has several bugs and I need to find the time to make a complete overhaul.
Thanks for the 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

No branches or pull requests

2 participants