- Added a description of internal storage and permissable range to the
Duration type.
- Adjusted formatting of `Duration` in a number of related function
Rustdoc blocks, to aid readability.
- Clarified comments for Duration::num_milliseconds().
- Added a new Duration::try_milliseconds() function, to attempt to
create a new milliseconds-based Duration, and return None if it
fails, based on checking against MAX and MIN. Currently, failure can
only happen for exactly one value, which is i64::MIN.
- Updated Duration::milliseconds() to call try_milliseconds() and
panic if None is returned. Although panicking in production code and
especially library code is bad, this is in keeping with current
Chrono behaviour. Note that this function is now no longer const.
- Updated the Duration::milliseconds() documentation to make it clear
that it now panics.
- Added documentation to Duration::microseconds() and nanoseconds() to
make it clear that they are infallible.
- All tests now pass, including the one previously ignored.
- Added Panics and Errors sections where appropriate, as these are
generally-expected and help draw attention to the fact that the
standard (i.e. non-try) constructors can panic. The Errors section
for the try constructors is common practice when returning None for
overflow situations as well as for functions actually returning a
Result.
- Added an further explanation of the behaviour of the seconds()
constructor.
- Minor additional readability edits.
- Added tests for creating the maximum and minimum allowable values of
Durations having a magnitude of seconds, testing the limits plus one
value beyond the limits in both directions. These tests all pass.
- Expanded the tests for creating the maximum and minimum allowable
values of Durations having a magnitude of milliseconds. These tests
examine the results in more detail, document what is being tested,
and also test one value beyond the limits in both directions.
Notably, the test for Duration::milliseconds() construction for
i64::MIN currently fails, as it is erroneously allowed. This test is
ignored for now, until the fix is applied.
- Expanded the tests for creating the maximum and minimum allowable
values of Durations having a magnitude of microseconds and
nanoseconds. These tests examine the results in more detail,
document what is being tested, and also test one value beyond the
limits in both directions. They also test the maximum reportable
value from .num_*() and the maximum storable value of the Duration
separately.
- Separated out the tests for MAX and MIN, for clarity.
- Added additional tests for addition and subtraction operations on
Durations, ensuring that equivalent tests are performed against both
operations, such as adding and subtracting zero, adding and
subtracting one nanosecond, and others.
- Added tests for greater-than and less-than comparison of two
Durations, to ensure that internal representation of partial seconds
is correctly ordered.
This is due to the mutually exclusive features in rkyv which
we expose now. `--all-features` will now activate them and the crate
will fail to compile rkyv. We work around this by defining
an explicit list of all mutually exclusive features to.
Unfortunately there isn't an easy way to share env variables
among different YAML files
(https://github.com/actions/runner/issues/655).
There also isn't a good way to specify `--all-features` minus
"just a few" (https://github.com/rust-lang/cargo/issues/3126)
aside from giving the complete list.
Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
rkyv by default serializes usize as u32. This isn't ideal
on most modern platforms and unfortunately is configured through
a feature flag.
If we just set `default-features = false` in the rkyv Cargo
dependency, the crate fails to compile because all the size features
are mutually exclusive. On the other hand if we want to
e.g., change the serialization of usize to 64-bit and
we also want to use chrono this currently fails to compile
because chrono always enables rkyv/size_32.
This re-exports the relevant rkyv features so users can
choose which serialization to enable. The approach
is similar to what the ordered-float crate does:
8111b34537/Cargo.toml (L37)
Signed-off-by: Gerd Zellweger <mail@gerdzellweger.com>
* Add from_timestamp_nanos
Add and implement from_timestamp_nanos and add unit test for it
* Fix lint check error
* Add pub(crate) for NANOS_PER_SEC
* Replace number with constant variable