Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
span: add Span::to_duration and TryFrom impls for Duration
This PR dips our toes into the water of integration with `std::time::Duration`. I do somewhat expect there to be more integration points, particularly in the datetime arithmetic APIs, but this at least paves a path for folks to _correctly_ convert between a `Duration` and a `Span`. The error cases for the new APIs will ensure you can never misuse these APIs. This adds a few new APIs: * `Span::is_positive`, since we already have `Span::is_negative` and `Span::is_zero`. * `Span::signum`, since it's signed and it's sometimes convenient. * `TryFrom<std::time::Duration> for Span`. * `TryFrom<Span> for std::time::Duration` that returns an error if the span is negative or has non-zero units bigger than days. * `Span::to_duration` that requires a relative date and can convert any positive span into a `Duration` (modulo overflow). Partially addresses #21 Fixes #40
- Loading branch information