Skip to content

Commit 6895e85

Browse files
Merge pull request #166 from gwbres/gnss_timescales
introducing GNSS timescales
2 parents a1ca5cb + a7f89a2 commit 6895e85

10 files changed

Lines changed: 538 additions & 132 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hifitime"
3-
version = "3.5.0"
3+
version = "3.6.0"
44
authors = ["Christopher Rabotin <christopher.rabotin@gmail.com>"]
55
description = "Ultra-precise date and time handling in Rust for scientific applications with leap second support"
66
homepage = "https://nyxspace.com/"

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ This library is validated against NASA/NAIF SPICE for the Ephemeris Time to Univ
3535
+ Terrestrial Time (TT)
3636
+ Ephemeris Time (ET) without the small perturbations as per NASA/NAIF SPICE leap seconds kernel
3737
+ Dynamic Barycentric Time (TDB), a higher fidelity ephemeris time
38-
+ Global Positioning System (GPS), and UNIX
38+
+ Global Positioning System (GPST)
39+
+ Galileo System Time (GST)
40+
+ BaiDou Time (BDT)
41+
+ UNIX
3942
## Non-features
4043
* Time-agnostic / date-only epochs. Hifitime only supports the combination of date and time, but the `Epoch::{at_midnight, at_noon}` is provided as a helper function.
4144

@@ -45,7 +48,7 @@ Put this in your `Cargo.toml`:
4548

4649
```toml
4750
[dependencies]
48-
hifitime = "3.5"
51+
hifitime = "3.6"
4952
```
5053

5154
## Examples:
@@ -281,7 +284,8 @@ In order to provide full interoperability with NAIF, hifitime uses the NAIF algo
281284

282285
# Changelog
283286

284-
## 3.5.1
287+
## 3.6.0
288+
+ Galileo System Time and BeiDou Time are now supported, huge thanks to [@gwbres](https://github.com/gwbres) for all that work!
285289
+ Significant speed improvement in the initialization of Epochs from their Gregorian representation, thanks [@conradludgate](https://github.com/conradludgate) for [#160](https://github.com/nyx-space/hifitime/pull/160).
286290
+ Epoch and Duration now have a `min` and `max` function which respectively returns a copy of the epoch/duration that is the smallest or the largest between `self` and `other`, cf. [#164](https://github.com/nyx-space/hifitime/issues/164).
287291
+ [Python] Duration and Epochs now support the operators `>`, `>=`, `<`, `<=`, `==`, and `!=`. Epoch now supports `init_from_gregorian` with a time scape, like in Rust. Epochs can also be subtracted from one another using the `timedelta` function, cf. [#162](https://github.com/nyx-space/hifitime/issues/162).

benches/bench_epoch.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ pub fn criterion_benchmark(c: &mut Criterion) {
66
c.bench_function("TBD seconds and JDE ET", |b| {
77
b.iter(|| {
88
let e = Epoch::from_gregorian_utc_hms(2015, 2, 7, 11, 22, 33);
9-
black_box(Epoch::from_tdb_seconds(e.as_tdb_seconds()));
10-
black_box(Epoch::from_jde_et(e.as_jde_et_days()));
9+
black_box(Epoch::from_tdb_seconds(e.to_tdb_seconds()));
10+
black_box(Epoch::from_jde_et(e.to_jde_et_days()));
1111

1212
let f: Epoch = e + black_box(50) * Unit::Second;
13-
black_box(f.as_tdb_seconds());
14-
black_box(f.as_jde_et_days());
13+
black_box(f.to_tdb_seconds());
14+
black_box(f.to_jde_et_days());
1515
})
1616
});
1717

1818
c.bench_function("TT", |b| {
1919
b.iter(|| {
2020
let e = Epoch::from_gregorian_utc_hms(2015, 2, 7, 11, 22, 33);
21-
e.as_tt_seconds();
21+
e.to_tt_seconds();
2222

2323
let f: Epoch = e + black_box(50) * Unit::Second;
24-
f.as_tt_seconds();
24+
f.to_tt_seconds();
2525
})
2626
});
2727

2828
c.bench_function("Duration to f64 seconds", |b| {
2929
b.iter(|| {
3030
let d: Duration = Unit::Second * black_box(3.0);
31-
d.in_seconds();
31+
d.to_seconds();
3232
})
3333
});
3434

examples/python/basic.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@
4747
print(time_series)
4848
for (num, epoch) in enumerate(time_series):
4949
print(f"#{num}:\t{epoch}")
50+
51+
e1 = Epoch.system_now()
52+
e3 = e1 + Unit.Day * 1.5998
53+
epoch_delta = e3.timedelta(e1)
54+
assert epoch_delta == Unit.Day * 1 + Unit.Hour * 14 + Unit.Minute * 23 + Unit.Second * 42.720
55+
print(epoch_delta)

src/asn1der.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ impl<'a> Decode<'a> for Epoch {
6262
TimeScale::ET => Self::from_et_duration(duration),
6363
TimeScale::TDB => Self::from_tdb_duration(duration),
6464
TimeScale::UTC => Self::from_utc_duration(duration),
65+
TimeScale::GPST => Self::from_gpst_duration(duration),
66+
TimeScale::GST => Self::from_gst_duration(duration),
67+
TimeScale::BDT => Self::from_bdt_duration(duration),
6568
})
6669
}
6770
}
@@ -89,7 +92,7 @@ impl<'a> Decode<'a> for Unit {
8992
// Testing the encoding and decoding of an Epoch inherently also tests the encoding and decoding of a Duration
9093
#[test]
9194
fn test_encdec() {
92-
for ts_u8 in 0..5 {
95+
for ts_u8 in 0..=7 {
9396
let ts: TimeScale = ts_u8.into();
9497

9598
let epoch = if ts == TimeScale::UTC {
@@ -104,6 +107,9 @@ fn test_encdec() {
104107
TimeScale::TT => epoch.to_tt_duration(),
105108
TimeScale::TDB => epoch.to_tdb_duration(),
106109
TimeScale::UTC => epoch.to_utc_duration(),
110+
TimeScale::GPST => epoch.to_gpst_duration(),
111+
TimeScale::GST => epoch.to_gst_duration(),
112+
TimeScale::BDT => epoch.to_bdt_duration(),
107113
};
108114

109115
let e_dur = epoch.to_duration();
@@ -128,7 +134,7 @@ fn test_encdec() {
128134
);
129135
}
130136

131-
for unit_u8 in 0..8 {
137+
for unit_u8 in 0..=7 {
132138
let unit: Unit = unit_u8.into();
133139

134140
// Create a buffer

src/duration.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl Default for Duration {
9292
impl Duration {
9393
/// Builds a new duration from the number of centuries and the number of nanoseconds
9494
#[must_use]
95+
#[deprecated(note = "Prefer from_parts()", since = "3.6.0")]
9596
pub fn new(centuries: i16, nanoseconds: u64) -> Self {
9697
let mut out = Self {
9798
centuries,

0 commit comments

Comments
 (0)