From 3e06e0c64e12ec9c05a15907495fdac51bc40bdc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 11:36:34 +0000 Subject: [PATCH 01/17] Update tabled requirement from 0.12.0 to 0.14.0 Updates the requirements on [tabled](https://github.com/zhiburt/tabled) to permit the latest version. - [Changelog](https://github.com/zhiburt/tabled/blob/master/CHANGELOG.md) - [Commits](https://github.com/zhiburt/tabled/commits/v0.14.0) --- updated-dependencies: - dependency-name: tabled dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 382c5f0..d39958f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ 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} +tabled = {version = "0.14.0", optional = true} openssl = { version = "0.10", features = ["vendored"], optional = true } [dev-dependencies] From f4103653066b8e4f6ff6fbbeb08b095e738cd709 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 17 Aug 2023 14:54:33 -0600 Subject: [PATCH 02/17] Update Cargo.toml -- version bump --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d39958f..38fb5d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hifitime" -version = "3.8.2" +version = "3.8.3" authors = ["Christopher Rabotin "] description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support" homepage = "https://nyxspace.com/" From b27b63adb1e199929a75bfecd2ec493bb8c2e2b1 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sun, 20 Aug 2023 09:21:18 -0600 Subject: [PATCH 03/17] Day of year formatting now parses elapsed time This is was an oversight of the code and testing. Fix #248 --- Cargo.toml | 23 ++++++++++++++--------- examples/python/basic.py | 2 +- examples/python/timescales.py | 2 +- src/asn1der.rs | 2 +- src/deprecated.rs | 2 +- src/duration.rs | 2 +- src/efmt/consts.rs | 2 +- src/efmt/format.rs | 18 ++++++++++++++++-- src/efmt/formatter.rs | 2 +- src/efmt/mod.rs | 2 +- src/epoch.rs | 2 +- src/errors.rs | 2 +- src/leap_seconds.rs | 2 +- src/leap_seconds_file.rs | 2 +- src/lib.rs | 2 +- src/month.rs | 2 +- src/parser.rs | 2 +- src/python.rs | 2 +- src/timescale.rs | 2 +- src/timeseries.rs | 2 +- src/timeunits.rs | 2 +- src/ut1.rs | 2 +- src/weekday.rs | 2 +- 23 files changed, 51 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 38fb5d1..48f14e5 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 c2e4820..a152384 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 162e40a..a301117 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 9928293..0dbc2ba 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 4b6e368..40da931 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 d733ac5..fb61825 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 020795f..3c2f21e 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 4333eb4..d4498b5 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,10 @@ 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); } + +#[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 3922910..922a85a 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 8f19328..cc0e9f8 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 9f82745..1b6d49c 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 a7eb91c..473b05d 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 54687c6..a02f166 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 a0a1dd4..efbad59 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 46e80fe..8e3a3fa 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 b0f7d98..8837dae 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 78e498d..7a4b482 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 ca95994..abbee37 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 4a14a84..876fc24 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 bc53f8a..d04fded 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 fc535b6..ac6ef85 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 e88afb4..bf3a360 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 fe3be0f..484f3ac 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. From 559c630d2f034a46284d4f9b7d3356651cc45633 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sun, 20 Aug 2023 09:39:48 -0600 Subject: [PATCH 04/17] Fix minor CI issues --- src/efmt/format.rs | 1 + tests/python/test_epoch.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/efmt/format.rs b/src/efmt/format.rs index d4498b5..e1819da 100644 --- a/src/efmt/format.rs +++ b/src/efmt/format.rs @@ -530,6 +530,7 @@ fn epoch_format_from_str() { 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(); diff --git a/tests/python/test_epoch.py b/tests/python/test_epoch.py index 0e2c726..7bafd52 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(): From aa9264170ebb0df9c4f1ae7a2272f711549bd863 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 11:08:32 +0000 Subject: [PATCH 05/17] Update pyo3 requirement from 0.19.0 to 0.20.0 Updates the requirements on [pyo3](https://github.com/pyo3/pyo3) to permit the latest version. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.19.0...v0.20.0) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 48f14e5..c4b9888 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ name = "hifitime" 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 } +pyo3 = { version = "0.20.0", features = ["extension-module"], optional = true } num-traits = { version = "0.2.15", default-features = false, features = [ "libm", ] } From 3235e59e60bf151892649f70afc98f5f7fe29398 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Thu, 16 Nov 2023 18:27:27 -0700 Subject: [PATCH 06/17] Version bump --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c4b9888..03dc8be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hifitime" -version = "3.8.4" +version = "3.8.5" authors = ["Christopher Rabotin "] description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support" homepage = "https://nyxspace.com/" From 3857594e7d7bb7f14f9d9feae25d491fc8908302 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Thu, 16 Nov 2023 18:41:33 -0700 Subject: [PATCH 07/17] Richcomp may be implemented by pyo3 v 0.20 --- .github/workflows/python.yml | 9 ++++++--- src/duration.rs | 12 ------------ tests/python/test_epoch.py | 13 ++++++++++++- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 36570d1..ea7e6e8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -36,6 +36,9 @@ jobs: args: --release --out dist --find-interpreter -F python sccache: 'true' manylinux: auto + before-script-linux: | + sudo apt-get update + sudo apt-get install -y libclang-dev - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -74,7 +77,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 @@ -105,7 +108,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Build wheels uses: PyO3/maturin-action@v1 with: diff --git a/src/duration.rs b/src/duration.rs index fb61825..38f7a51 100644 --- a/src/duration.rs +++ b/src/duration.rs @@ -729,18 +729,6 @@ impl Duration { *self == other } - #[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, - } - } - // Python constructors #[cfg(feature = "python")] diff --git a/tests/python/test_epoch.py b/tests/python/test_epoch.py index 7bafd52..1e39c8f 100644 --- a/tests/python/test_epoch.py +++ b/tests/python/test_epoch.py @@ -1,4 +1,4 @@ -from hifitime import Epoch, TimeSeries, Unit +from hifitime import Epoch, TimeSeries, Unit, Duration from datetime import datetime @@ -44,3 +44,14 @@ def test_time_series(): print(f"#{num}:\t{epoch}") assert num == 10 + +def test_duration_eq(): + """ + Checks that Duration comparisons work + """ + + assert Unit.Second * 0.0 == Duration("0 ns") + assert Unit.Second * 1.0 >= Duration("0 ns") + assert Unit.Second * 1.0 > Duration("0 ns") + assert Duration("0 ns") <= Unit.Second * 1.0 + assert Duration("0 ns") < Unit.Second * 1.0 \ No newline at end of file From 3ba8fb5c8e4f5b8a36e1fb49bc14ea1e2417d29c Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sat, 18 Nov 2023 12:30:48 -0700 Subject: [PATCH 08/17] Implement lt,le,gt,ge --- .github/workflows/python.yml | 13 +++++-------- pyproject.toml | 4 ++-- src/duration.rs | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index ea7e6e8..7b2e847 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -1,4 +1,4 @@ -# This file is autogenerated by maturin v0.14.17 +# This file is autogenerated by maturin v1.3.2 # To update, run # # maturin generate-ci --pytest -o .github/workflows/python.yml github @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.10' - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -36,9 +36,6 @@ jobs: args: --release --out dist --find-interpreter -F python sccache: 'true' manylinux: auto - before-script-linux: | - sudo apt-get update - sudo apt-get install -y libclang-dev - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -77,7 +74,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.10' architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 @@ -108,7 +105,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.10' - name: Build wheels uses: PyO3/maturin-action@v1 with: @@ -159,4 +156,4 @@ jobs: MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} with: command: upload - args: --skip-existing * + args: --non-interactive --skip-existing * diff --git a/pyproject.toml b/pyproject.toml index fd60678..1660726 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["maturin>=0.13,<0.14"] +requires = ["maturin>=1.3,<1.4"] build-backend = "maturin" [project] @@ -15,4 +15,4 @@ classifiers = [ [tool.yapf] based_on_style = "google" spaces_before_comment = 4 -column_limit = 100 \ No newline at end of file +column_limit = 100 diff --git a/src/duration.rs b/src/duration.rs index 38f7a51..43260d8 100644 --- a/src/duration.rs +++ b/src/duration.rs @@ -729,6 +729,26 @@ impl Duration { *self == other } + #[cfg(feature = "python")] + 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 #[cfg(feature = "python")] From b18ad4b8d6bd02bd4696084ef09f0e859b9a61de Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sat, 18 Nov 2023 12:49:06 -0700 Subject: [PATCH 09/17] Update UT1 test from JPL data --- tests/ut1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ut1.rs b/tests/ut1.rs index 2934e88..2f6a29c 100644 --- a/tests/ut1.rs +++ b/tests/ut1.rs @@ -46,6 +46,6 @@ fn test_ut1_from_jpl() { let ut1_epoch = epoch.to_ut1(provider); assert_eq!( format!("{:x}", ut1_epoch), - "2022-01-03T03:05:06.679020600 TAI", + "2022-01-03T03:05:43.789100000 TAI", ); } From 7dd7a07ef91e26d4755ba5b5ae8abfb31edcdcd5 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sat, 18 Nov 2023 13:00:21 -0700 Subject: [PATCH 10/17] Bump MSRV --- .github/workflows/tests.yml | 2 +- README.md | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e8d4a7e..2ee7e22 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] rust: - - { version: "1.64", name: MSRV } + - { version: "1.70", name: MSRV } - { version: stable, name: stable } runs-on: ${{ matrix.os }} diff --git a/README.md b/README.md index ea93d2c..3f57bbe 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,7 @@ In Python: [![hifitime on crates.io][cratesio-image]][cratesio] [![hifitime on docs.rs][docsrs-image]][docsrs] -[![minimum rustc: 1.64](https://img.shields.io/badge/minimum%20rustc-1.64-yellowgreen?logo=rust)](https://www.whatrustisit.com) +[![minimum rustc: 1.70](https://img.shields.io/badge/minimum%20rustc-1.70-yellowgreen?logo=rust)](https://www.whatrustisit.com) [![Build Status](https://github.com/nyx-space/hifitime/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/nyx-space/hifitime/actions) [![Build Status](https://github.com/nyx-space/hifitime/actions/workflows/formal_verification.yml/badge.svg?branch=master)](https://github.com/nyx-space/hifitime/actions) [![codecov](https://codecov.io/gh/nyx-space/hifitime/branch/master/graph/badge.svg?token=l7zU57rUGs)](https://codecov.io/gh/nyx-space/hifitime) @@ -309,6 +309,12 @@ In order to provide full interoperability with NAIF, hifitime uses the NAIF algo # Changelog +## 3.8.5 + +Changes from 3.8.2 are only dependency upgrades until this release. + +Minimum Supported Rust version bumped from 1.64 to **1.70**. + ## 3.8.2 + Clarify README and add a section comparing Hifitime to `time` and `chrono`, cf. [#221](https://github.com/nyx-space/hifitime/issues/221) + Fix incorrect printing of Gregorian dates prior to to 1900, cf. [#204](https://github.com/nyx-space/hifitime/issues/204) From 4ee554db03a879cdc6a3e18e902ce2123d79bf89 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sat, 18 Nov 2023 13:04:40 -0700 Subject: [PATCH 11/17] Disable scache --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7b2e847..30a2c2c 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -34,7 +34,7 @@ jobs: with: target: ${{ matrix.target }} args: --release --out dist --find-interpreter -F python - sccache: 'true' + sccache: 'false' manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 From 9f76174ce010f2210bf43cae17319c7e29ad75b8 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sat, 18 Nov 2023 14:16:22 -0700 Subject: [PATCH 12/17] Disable manulinux --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 30a2c2c..6dd68f6 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -35,7 +35,7 @@ jobs: target: ${{ matrix.target }} args: --release --out dist --find-interpreter -F python sccache: 'false' - manylinux: auto + manylinux: false - name: Upload wheels uses: actions/upload-artifact@v3 with: From 11c524686fdd5ad6820d38c2a6bdf898b022bc82 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sat, 18 Nov 2023 14:34:51 -0700 Subject: [PATCH 13/17] Switch build for Python --- .github/workflows/python.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6dd68f6..69d88cb 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -28,14 +28,27 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} args: --release --out dist --find-interpreter -F python - sccache: 'false' - manylinux: false + manylinux: auto + before-script-linux: | + # If we're running on rhel centos, install needed packages. + if command -v yum &> /dev/null; then + yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic + + # If we're running on i686 we need to symlink libatomic + # in order to build openssl with -latomic flag. + if [[ ! -d "/usr/lib64" ]]; then + ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so + fi + else + # If we're running on debian-based system. + apt update -y && apt-get install -y libssl-dev openssl pkg-config + fi - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -74,7 +87,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 @@ -105,7 +118,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Build wheels uses: PyO3/maturin-action@v1 with: From d6324a5d2b78b42e0c5a9d25e97330c5ef98424b Mon Sep 17 00:00:00 2001 From: Thomas Antony Date: Tue, 5 Dec 2023 20:26:59 -0800 Subject: [PATCH 14/17] Add "wasm-bindgen" feature to Cargo.toml with dependencies --- Cargo.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 03dc8be..887415a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,21 @@ 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" From ccc2398989459b86380207643fc3cb5f0f85e31f Mon Sep 17 00:00:00 2001 From: Thomas Antony Date: Sat, 9 Dec 2023 15:01:35 -0800 Subject: [PATCH 15/17] Add system_time.rs and update lib.rs --- src/lib.rs | 3 +++ src/system_time.rs | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/system_time.rs diff --git a/src/lib.rs b/src/lib.rs index 8e3a3fa..7402011 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,3 +141,6 @@ pub mod python; #[cfg(feature = "std")] extern crate core; + +#[cfg(feature = "std")] +mod system_time; diff --git a/src/system_time.rs b/src/system_time.rs new file mode 100644 index 0000000..03d656b --- /dev/null +++ b/src/system_time.rs @@ -0,0 +1,22 @@ +use crate::{Duration, Errors}; + +#[cfg(target_arch = "wasm32")] +pub(crate) fn duration_since_unix_epoch() -> Result { + { + use crate::Unit; + use wasm_bindgen_rs::prelude::*; + js_sys::Reflect::get(&js_sys::global(), &JsValue::from_str("performance")) + .map_err(|_| Errors::SystemTimeError) + .map(|performance| { + performance.unchecked_into::().now() * Unit::Second + }) + } +} + +#[cfg(not(target_arch = "wasm32"))] +pub(crate) fn duration_since_unix_epoch() -> Result { + std::time::SystemTime::now() + .duration_since(std::time::SystemTime::UNIX_EPOCH) + .map_err(|_| Errors::SystemTimeError) + .and_then(|d| d.try_into().map_err(|_| Errors::SystemTimeError)) +} From 85af13f79e8d97c9c04e89aca8148425df32d1c3 Mon Sep 17 00:00:00 2001 From: Thomas Antony Date: Tue, 5 Dec 2023 20:27:45 -0800 Subject: [PATCH 16/17] Update epoch.rs to use new system_time module --- src/epoch.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/epoch.rs b/src/epoch.rs index 1b6d49c..24c625f 100644 --- a/src/epoch.rs +++ b/src/epoch.rs @@ -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}; @@ -630,6 +628,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 { @@ -2827,12 +2831,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 { - 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)) } } From bd5f7eb9f5885c5250b131a4060352b230c190c7 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sun, 10 Dec 2023 21:17:59 -0700 Subject: [PATCH 17/17] Update crate version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 887415a..38ad281 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hifitime" -version = "3.8.5" +version = "3.8.6" authors = ["Christopher Rabotin "] description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support" homepage = "https://nyxspace.com/"