-
-
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 #253 from nyx-space/248-epochfrom_format_str-does-…
…not-set-hours-minutes-and-seconds Day of year formatting now parses elapsed time
- Loading branch information
Showing
24 changed files
with
53 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "hifitime" | ||
version = "3.8.3" | ||
version = "3.8.4" | ||
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,14 +18,19 @@ 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} | ||
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.14.0", 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 } | ||
|
||
[dev-dependencies] | ||
|
@@ -42,7 +47,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
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 |
---|---|---|
@@ -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 |
---|---|---|
@@ -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. | ||
|
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. | ||
|
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 |
---|---|---|
@@ -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 |
---|---|---|
@@ -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