diff --git a/Cargo.toml b/Cargo.toml index 38fb5d11..48f14e5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hifitime" -version = "3.8.3" +version = "3.8.4" authors = ["Christopher Rabotin "] 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" diff --git a/examples/python/basic.py b/examples/python/basic.py index c2e48209..a1523842 100644 --- a/examples/python/basic.py +++ b/examples/python/basic.py @@ -1,6 +1,6 @@ """ * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/examples/python/timescales.py b/examples/python/timescales.py index 162e40a9..a3011178 100644 --- a/examples/python/timescales.py +++ b/examples/python/timescales.py @@ -1,6 +1,6 @@ """ * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/asn1der.rs b/src/asn1der.rs index 99282935..0dbc2ba8 100644 --- a/src/asn1der.rs +++ b/src/asn1der.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/deprecated.rs b/src/deprecated.rs index 4b6e3685..40da9311 100644 --- a/src/deprecated.rs +++ b/src/deprecated.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/duration.rs b/src/duration.rs index d733ac5f..fb618256 100644 --- a/src/duration.rs +++ b/src/duration.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/efmt/consts.rs b/src/efmt/consts.rs index 020795f2..3c2f21e4 100644 --- a/src/efmt/consts.rs +++ b/src/efmt/consts.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/efmt/format.rs b/src/efmt/format.rs index 4333eb44..e1819dab 100644 --- a/src/efmt/format.rs +++ b/src/efmt/format.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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"); +} diff --git a/src/efmt/formatter.rs b/src/efmt/formatter.rs index 3922910a..922a85ad 100644 --- a/src/efmt/formatter.rs +++ b/src/efmt/formatter.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/efmt/mod.rs b/src/efmt/mod.rs index 8f193283..cc0e9f8f 100644 --- a/src/efmt/mod.rs +++ b/src/efmt/mod.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/epoch.rs b/src/epoch.rs index 9f827454..1b6d49ca 100644 --- a/src/epoch.rs +++ b/src/epoch.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/errors.rs b/src/errors.rs index a7eb91c2..473b05dc 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/leap_seconds.rs b/src/leap_seconds.rs index 54687c6b..a02f166d 100644 --- a/src/leap_seconds.rs +++ b/src/leap_seconds.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/leap_seconds_file.rs b/src/leap_seconds_file.rs index a0a1dd46..efbad593 100644 --- a/src/leap_seconds_file.rs +++ b/src/leap_seconds_file.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/lib.rs b/src/lib.rs index 46e80fe8..8e3a3fa6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/month.rs b/src/month.rs index b0f7d984..8837daec 100644 --- a/src/month.rs +++ b/src/month.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/parser.rs b/src/parser.rs index 78e498d9..7a4b4828 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/python.rs b/src/python.rs index ca95994d..abbee374 100644 --- a/src/python.rs +++ b/src/python.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/timescale.rs b/src/timescale.rs index 4a14a846..876fc241 100644 --- a/src/timescale.rs +++ b/src/timescale.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/timeseries.rs b/src/timeseries.rs index bc53f8ae..d04fded5 100644 --- a/src/timeseries.rs +++ b/src/timeseries.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/timeunits.rs b/src/timeunits.rs index fc535b60..ac6ef850 100644 --- a/src/timeunits.rs +++ b/src/timeunits.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/ut1.rs b/src/ut1.rs index e88afb46..bf3a3606 100644 --- a/src/ut1.rs +++ b/src/ut1.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/src/weekday.rs b/src/weekday.rs index fe3be0fd..484f3acf 100644 --- a/src/weekday.rs +++ b/src/weekday.rs @@ -1,6 +1,6 @@ /* * Hifitime, part of the Nyx Space tools - * Copyright (C) 2022 Christopher Rabotin et al. (cf. AUTHORS.md) + * Copyright (C) 2023 Christopher Rabotin 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. diff --git a/tests/python/test_epoch.py b/tests/python/test_epoch.py index 0e2c7265..7bafd521 100644 --- a/tests/python/test_epoch.py +++ b/tests/python/test_epoch.py @@ -22,7 +22,7 @@ def test_utcnow(): dt = datetime.utcnow() # Hifitime uses a different clock to Python and print down to the nanosecond - assert dt.isoformat()[:21] == f"{epoch}"[:21] + assert dt.isoformat()[:20] == f"{epoch}"[:20] def test_time_series():