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

when:so does not fail on all malformed date-times #6870

Open
jackfoxy opened this issue Dec 7, 2023 · 1 comment
Open

when:so does not fail on all malformed date-times #6870

jackfoxy opened this issue Dec 7, 2023 · 1 comment
Labels

Comments

@jackfoxy
Copy link

jackfoxy commented Dec 7, 2023

Describe the bug
When parsing date-time with when:so and the fractional seconds are malformed it truncates the result to the hour/minute/second component.
When hour/minute/second is malformed it truncates to date.

To Reproduce
(wonk (when:so [[1 1] "2020.12.25..7.15.1..9ef"]))
[[%.y 2.020] 12 25 [7 15 1 ~]]

(wonk (when:so [[1 1] "2020.12.25..7.15."]))
[[%.y 2.020] 12 25 [0 0 0 ~]]

Expected behaviour
hoon expression failed

The fix
Change 2 LOC in hoon.hoon when:so

++  when
  ~+
  ;~  plug
    %+  cook
      |=([a=@ b=?] [b a])
    ;~(plug dim:ag ;~(pose (cold | hep) (easy &)))
    ;~(pfix dot mot:ag)   ::  month
    ;~(pfix dot dip:ag)   ::  day
    ;~  pose
      ;~  pfix
        ;~(plug dot dot)
        ;~  plug
          dum:ag
          ;~(pfix dot dum:ag)
          ;~(pfix dot dum:ag)
::          ;~(pose ;~(pfix ;~(plug dot dot) (most dot qix:ab)) (easy ~))
          ;~(pose ;~(pfix ;~(plug dot dot) (most dot qix:ab)) ;~(less dot (easy ~)))
        ==
      ==
::      (easy [0 0 0 ~])
      ;~(less dot (easy [0 0 0 ~]))
    ==
  ==
@jackfoxy jackfoxy added the bug label Dec 7, 2023
@jackfoxy
Copy link
Author

jackfoxy commented Dec 7, 2023

Unit tests: I don't see an existing file appropriate for unit testing this.
I suggest adding time.hoon to tests/sys, or make a new directory path in tests. This file would be appropriate for testing time and time-range parsing and manipulations.

Happy to submit a PR for this issue.

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

No branches or pull requests

1 participant