Skip to content

Commit d124c90

Browse files
Merge pull request #350 from nyx-space/bug/gh-349-duration-from-str-negative
Fix parsing of microseconds with UTF8 symbol and parsing negative durations
2 parents ee1b1a9 + c10ba2b commit d124c90

File tree

9 files changed

+335
-214
lines changed

9 files changed

+335
-214
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hifitime"
3-
version = "4.0.1"
3+
version = "4.0.2"
44
authors = ["Christopher Rabotin <christopher.rabotin@gmail.com>"]
55
description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support"
66
homepage = "https://nyxspace.com/"

benches/crit_duration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
1010
b.iter(|| {
1111
let interval_length_s: f64 = 6311433599.999999;
1212
let interval_length: Duration = black_box(interval_length_s * Unit::Second);
13-
interval_length.to_parts().1;
13+
interval_length.to_parts();
1414
})
1515
},
1616
);

src/duration/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ pub mod ops;
5757
///
5858
/// **Important conventions:**
5959
/// 1. The negative durations can be mentally modeled "BC" years. One hours before 01 Jan 0000, it was "-1" years but 365 days and 23h into the current day.
60-
/// It was decided that the nanoseconds corresponds to the nanoseconds _into_ the current century. In other words,
61-
/// a duration with centuries = -1 and nanoseconds = 0 is _a greater duration_ (further from zero) than centuries = -1 and nanoseconds = 1.
62-
/// Duration zero minus one nanosecond returns a century of -1 and a nanosecond set to the number of nanoseconds in one century minus one.
63-
/// That difference is exactly 1 nanoseconds, where the former duration is "closer to zero" than the latter.
64-
/// As such, the largest negative duration that can be represented sets the centuries to i16::MAX and its nanoseconds to NANOSECONDS_PER_CENTURY.
60+
/// It was decided that the nanoseconds corresponds to the nanoseconds _into_ the current century. In other words,
61+
/// a duration with centuries = -1 and nanoseconds = 0 is _a greater duration_ (further from zero) than centuries = -1 and nanoseconds = 1.
62+
/// Duration zero minus one nanosecond returns a century of -1 and a nanosecond set to the number of nanoseconds in one century minus one.
63+
/// That difference is exactly 1 nanoseconds, where the former duration is "closer to zero" than the latter.
64+
/// As such, the largest negative duration that can be represented sets the centuries to i16::MAX and its nanoseconds to NANOSECONDS_PER_CENTURY.
6565
/// 2. It was also decided that opposite durations are equal, e.g. -15 minutes == 15 minutes. If the direction of time matters, use the signum function.
6666
///
6767
/// (Python documentation hints)

0 commit comments

Comments
 (0)