Skip to content

Commit

Permalink
Merge pull request #264 from nyx-space/master
Browse files Browse the repository at this point in the history
Integrate 3.8.6 into 4.0.0-dev
  • Loading branch information
ChristopherRabotin authored Dec 11, 2023
2 parents 8396a4d + bd5f7eb commit 8ef79ee
Show file tree
Hide file tree
Showing 30 changed files with 163 additions and 62 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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: 'true'
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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -156,4 +169,4 @@ jobs:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing *
args: --non-interactive --skip-existing *
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
40 changes: 30 additions & 10 deletions Cargo.toml
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 <christopher.rabotin@gmail.com>"]
description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support"
homepage = "https://nyxspace.com/"
Expand All @@ -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"
Expand All @@ -42,7 +62,7 @@ ut1 = ["std", "reqwest", "tabled", "openssl"]

[[bench]]
name = "crit_epoch"
harness = false
harness = false

[[bench]]
name = "crit_duration"
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/python/basic.py
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
2 changes: 1 addition & 1 deletion examples/python/timescales.py
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["maturin>=0.13,<0.14"]
requires = ["maturin>=1.3,<1.4"]
build-backend = "maturin"

[project]
Expand All @@ -15,4 +15,4 @@ classifiers = [
[tool.yapf]
based_on_style = "google"
spaces_before_comment = 4
column_limit = 100
column_limit = 100
2 changes: 1 addition & 1 deletion src/asn1der.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
2 changes: 1 addition & 1 deletion src/deprecated.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
28 changes: 18 additions & 10 deletions src/duration.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/efmt/consts.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
19 changes: 17 additions & 2 deletions src/efmt/format.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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");
}
2 changes: 1 addition & 1 deletion src/efmt/formatter.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
2 changes: 1 addition & 1 deletion src/efmt/mod.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
19 changes: 11 additions & 8 deletions src/epoch.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/errors.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
2 changes: 1 addition & 1 deletion src/leap_seconds.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
2 changes: 1 addition & 1 deletion src/leap_seconds_file.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/*
* Hifitime, part of the Nyx Space tools
* Copyright (C) 2022 Christopher Rabotin <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down Expand Up @@ -141,3 +141,6 @@ pub mod python;

#[cfg(feature = "std")]
extern crate core;

#[cfg(feature = "std")]
mod system_time;
2 changes: 1 addition & 1 deletion src/month.rs
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 <christopher.rabotin@gmail.com> et al. (cf. AUTHORS.md)
* Copyright (C) 2023 Christopher Rabotin <christopher.rabotin@gmail.com> 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.
Expand Down
Loading

0 comments on commit 8ef79ee

Please sign in to comment.