-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from nyx-space/master
Integrate 3.8.6 into 4.0.0-dev
- Loading branch information
Showing
30 changed files
with
163 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "hifitime" | ||
version = "3.8.2" | ||
version = "3.8.6" | ||
authors = ["Christopher Rabotin <[email protected]>"] | ||
description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support" | ||
homepage = "https://nyxspace.com/" | ||
|
@@ -18,16 +18,36 @@ crate-type = ["cdylib", "rlib"] | |
name = "hifitime" | ||
|
||
[dependencies] | ||
serde = {version = "1.0.155", optional = true} | ||
serde_derive = {version = "1.0.155", optional = true} | ||
der = {version = "0.6.1", features = ["derive", "real"], optional = true} | ||
pyo3 = { version = "0.19.0", features = ["extension-module"], optional = true } | ||
num-traits = {version = "0.2.15", default-features = false, features = ["libm"]} | ||
lexical-core = {version = "0.8.5", default-features = false, features = ["parse-integers", "parse-floats"]} | ||
reqwest = { version = "0.11", features = ["blocking", "json"], optional = true} | ||
tabled = {version = "0.12.0", optional = true} | ||
serde = { version = "1.0.155", optional = true } | ||
serde_derive = { version = "1.0.155", optional = true } | ||
der = { version = "0.6.1", features = ["derive", "real"], optional = true } | ||
pyo3 = { version = "0.20.0", features = ["extension-module"], optional = true } | ||
num-traits = { version = "0.2.15", default-features = false, features = [ | ||
"libm", | ||
] } | ||
lexical-core = { version = "0.8.5", default-features = false, features = [ | ||
"parse-integers", | ||
"parse-floats", | ||
] } | ||
reqwest = { version = "0.11", features = ["blocking", "json"], optional = true } | ||
tabled = { version = "0.14.0", optional = true } | ||
openssl = { version = "0.10", features = ["vendored"], optional = true } | ||
|
||
[target.wasm32-unknown-unknown.dependencies] | ||
js-sys = { version = "0.3"} | ||
wasm-bindgen_rs = { package = "wasm-bindgen", version = "0.2"} | ||
web-sys = { version = "0.3", features = ['Window', 'Performance', 'PerformanceTiming'] } | ||
|
||
[target.wasm32-unknown-emscripten.dependencies] | ||
js-sys = { version = "0.3"} | ||
wasm-bindgen_rs = { package = "wasm-bindgen", version = "0.2"} | ||
web-sys = { version = "0.3", features = ['Window', 'Performance', 'PerformanceTiming'] } | ||
|
||
[target.asmjs-unknown-emscripten.dependencies] | ||
js-sys = { version = "0.3"} | ||
wasm-bindgen_rs = { package = "wasm-bindgen", version = "0.2"} | ||
web-sys = { version = "0.3", features = ['Window', 'Performance', 'PerformanceTiming'] } | ||
|
||
[dev-dependencies] | ||
serde_json = "1.0.91" | ||
criterion = "0.5.1" | ||
|
@@ -42,7 +62,7 @@ ut1 = ["std", "reqwest", "tabled", "openssl"] | |
|
||
[[bench]] | ||
name = "crit_epoch" | ||
harness = false | ||
harness = false | ||
|
||
[[bench]] | ||
name = "crit_duration" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
""" | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
""" | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
@@ -730,15 +730,23 @@ impl Duration { | |
} | ||
|
||
#[cfg(feature = "python")] | ||
fn __richcmp__(&self, other: Self, op: CompareOp) -> bool { | ||
match op { | ||
CompareOp::Lt => *self < other, | ||
CompareOp::Le => *self <= other, | ||
CompareOp::Eq => *self == other, | ||
CompareOp::Ne => *self != other, | ||
CompareOp::Gt => *self > other, | ||
CompareOp::Ge => *self >= other, | ||
} | ||
fn __le__(&self, other: Self) -> bool { | ||
*self <= other | ||
} | ||
|
||
#[cfg(feature = "python")] | ||
fn __lt__(&self, other: Self) -> bool { | ||
*self < other | ||
} | ||
|
||
#[cfg(feature = "python")] | ||
fn __ge__(&self, other: Self) -> bool { | ||
*self >= other | ||
} | ||
|
||
#[cfg(feature = "python")] | ||
fn __gt__(&self, other: Self) -> bool { | ||
*self > other | ||
} | ||
|
||
// Python constructors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
@@ -309,7 +309,14 @@ impl Format { | |
}; | ||
|
||
let epoch = match day_of_year { | ||
Some(days) => Epoch::from_day_of_year(decomposed[0], days, ts), | ||
Some(days) => { | ||
// Parse the elapsed time in the given day | ||
let elapsed = (decomposed[3] as i64) * Unit::Hour | ||
+ (decomposed[4] as i64) * Unit::Minute | ||
+ (decomposed[5] as i64) * Unit::Second | ||
+ (decomposed[6] as i64) * Unit::Nanosecond; | ||
Epoch::from_day_of_year(decomposed[0], days, ts) + elapsed | ||
} | ||
None => Epoch::maybe_from_gregorian( | ||
decomposed[0], | ||
decomposed[1].try_into().unwrap(), | ||
|
@@ -522,3 +529,11 @@ fn epoch_format_from_str() { | |
let fmt = Format::from_str("%a, %d %b %Y %H:%M:%S").unwrap(); | ||
assert_eq!(fmt, crate::efmt::consts::RFC2822); | ||
} | ||
|
||
#[cfg(feature = "std")] | ||
#[test] | ||
fn gh_248_regression() { | ||
let e = Epoch::from_format_str("2023-117T12:55:26", "%Y-%jT%H:%M:%S").unwrap(); | ||
|
||
assert_eq!(format!("{e}"), "2023-04-28T12:55:26 UTC"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
@@ -44,8 +44,6 @@ use crate::leap_seconds_file::LeapSecondsFile; | |
use serde_derive::{Deserialize, Serialize}; | ||
|
||
use core::str::FromStr; | ||
#[cfg(feature = "std")] | ||
use std::time::SystemTime; | ||
|
||
#[cfg(not(feature = "std"))] | ||
use num_traits::{Euclid, Float}; | ||
|
@@ -676,6 +674,12 @@ impl Epoch { | |
) | ||
} | ||
|
||
#[must_use] | ||
/// Initialize an Epoch from the provided duration since UTC midnight 1970 January 01. | ||
pub fn from_unix_duration(duration: Duration) -> Self { | ||
Self::from_utc_duration(UNIX_REF_EPOCH.to_utc_duration() + duration) | ||
} | ||
|
||
#[must_use] | ||
/// Initialize an Epoch from the provided UNIX second timestamp since UTC midnight 1970 January 01. | ||
pub fn from_unix_seconds(seconds: f64) -> Self { | ||
|
@@ -2933,12 +2937,11 @@ impl Epoch { | |
impl Epoch { | ||
/// Initializes a new Epoch from `now`. | ||
/// WARNING: This assumes that the system time returns the time in UTC (which is the case on Linux) | ||
/// Uses [`std::time::SystemTime::now`](https://doc.rust-lang.org/std/time/struct.SystemTime.html#method.now) under the hood | ||
/// Uses [`std::time::SystemTime::now`](https://doc.rust-lang.org/std/time/struct.SystemTime.html#method.now) | ||
/// or javascript interop under the hood | ||
pub fn now() -> Result<Self, Errors> { | ||
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) { | ||
Ok(std_duration) => Ok(Self::from_unix_seconds(std_duration.as_secs_f64())), | ||
Err(_) => Err(Errors::SystemTimeError), | ||
} | ||
let duration = crate::system_time::duration_since_unix_epoch()?; | ||
Ok(Self::from_unix_duration(duration)) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
@@ -141,3 +141,6 @@ pub mod python; | |
|
||
#[cfg(feature = "std")] | ||
extern crate core; | ||
|
||
#[cfg(feature = "std")] | ||
mod system_time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* Hifitime, part of the Nyx Space tools | ||
* Copyright (C) 2022 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* Copyright (C) 2023 Christopher Rabotin <[email protected]> et al. (cf. AUTHORS.md) | ||
* This Source Code Form is subject to the terms of the Apache | ||
* v. 2.0. If a copy of the Apache License was not distributed with this | ||
* file, You can obtain one at https://www.apache.org/licenses/LICENSE-2.0. | ||
|
Oops, something went wrong.