-
Notifications
You must be signed in to change notification settings - Fork 0
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
Iso-duration #12
Iso-duration #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking as draft until #10 is merged, as this includes the diff from that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is https://pypi.org/project/isoduration/ usable? If there's an off-the-shelf package that we can lean on, that'd be preferable to a re-implementation IMO.
I ran into the same issue in noaa-cdr: https://github.com/stactools-packages/noaa-cdr/blob/db4ebdc633a2cb1f27874b039edcbe761b81b214/src/stactools/noaa_cdr/time.py#L191-L215. There, I knew I had a limited subset of cases to handle, so I did re-implement, but since this is supposed to be a general-use library, we should avoid re-implementation if possible IMO.
After some investigation I can say: unfortunately The other option For temporal dimensions we have a single conversion from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iso_duration
deserves some unit tests, I think, to ensure we're handling some common cases properly. At minimum:
- One year
- One month
- One day
- One week
- One hour
- One second
- A duration that has everything
- A duration that doesn't have any hours, minutes, or seconds
That will help future developers understand the expected behavior of the function.
Question: do we need a reverse function, one that parses a string into a timedelta?
This has not yet come up. Currently we are building te timedeltas from netcdf/zarr metadata. They are usually expressed as somthing like |
Fixing results for various cases Adding tests for iso_format
I added a couple of unit-tests |
Appreciate the fixups, looks good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@constantinius this is not passing CI so needs fixes before it can go in and we release.
Proper ISO 8601 duration encoding for temporal dimension steps