Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Epoch to its own time scale #241

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c8648ef
epoch::from_duration slight improvements
gwbres May 27, 2023
0062d93
rename epoch inner duration
gwbres May 28, 2023
b6580ea
introducing to_time_scale
gwbres May 28, 2023
5de034b
introducing week unit
gwbres May 28, 2023
9d0afbd
fix eq and comparison issue: compare in same time scale
gwbres May 28, 2023
7ffad08
Update src/epoch.rs
gwbres May 30, 2023
e477272
Update src/epoch.rs
gwbres May 30, 2023
17f0568
working on compute_gregorian()
gwbres May 30, 2023
6df531a
Fixed unit tests
ChristopherRabotin Jun 12, 2023
c6218ef
Spread out duration.rs into a module
ChristopherRabotin Jun 12, 2023
846418e
Merge branch '4.0.0-dev' into 4.0.0-dev-gh-237
ChristopherRabotin Jun 12, 2023
0885a42
Modicum of progress but TDB/ET conversions are broken
ChristopherRabotin Jun 16, 2023
ac709df
Progress in time scale conversion with new arch
ChristopherRabotin Jun 17, 2023
e70be45
Also convert the time scale with leap seconds into the one without le…
ChristopherRabotin Jun 17, 2023
5c4a2eb
Fix gregorian computation with new arch
ChristopherRabotin Jun 17, 2023
fb0e809
Might have found a bug in duration decompose
ChristopherRabotin Jun 17, 2023
3606ef6
Fix decompose in duration
ChristopherRabotin Jun 17, 2023
53d6ca5
Replace references to `self.duration` to ensure TAI conversion
ChristopherRabotin Jun 17, 2023
5899c93
Likely bug to be fixed
ChristopherRabotin Jun 17, 2023
faa31cc
add more tests
Sep 2, 2023
8e19bfa
improve to_time_scale, initial_year..
Sep 2, 2023
d1e6236
on the right track..
Sep 2, 2023
ce02a28
on the right track..
Sep 2, 2023
a225d8d
working on tai_utc
Sep 2, 2023
7e10d82
working on tai_utc
Sep 2, 2023
e95b519
working on tai_utc
Sep 2, 2023
324c676
working on tai_utc
Sep 2, 2023
295f46f
change print behavior
Sep 2, 2023
52fec8f
revert to_time_scale()
Sep 3, 2023
233d449
time_scale.decompose()
Sep 3, 2023
75350b1
revert from_gregorian and compute_gregorian
Sep 3, 2023
88e544d
revert to previously almost correct gregorian
Sep 3, 2023
49c2a23
Modify Epoch.debug() behavior
Sep 18, 2023
f47d416
modify PartialEq behavior
Sep 29, 2023
97ad926
reduce indentation
gwbres Sep 29, 2023
451c29a
...
gwbres Sep 29, 2023
7f6441e
...
gwbres Sep 29, 2023
729160d
fix to_bdt_duration
gwbres Sep 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/asn1der.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn test_encdec() {
let encdec_epoch = Epoch::from_der(&buf).unwrap();
// Check that the duration in J1900 TAI is the same
assert_eq!(
encdec_epoch.duration_since_j1900_tai, epoch.duration_since_j1900_tai,
encdec_epoch.duration, epoch.duration,
"Decoded epoch incorrect ({ts:?}):\ngot: {encdec_epoch}\nexp: {epoch}",
);
// Check that the time scale used is preserved
Expand Down
36 changes: 20 additions & 16 deletions src/deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@ impl Epoch {
self.to_duration_since_j1900()
}

#[must_use]
#[deprecated(
note = "Prefix for this function is now `to_` instead of `as_`.",
since = "3.5.0"
)]
pub fn as_duration_since_j1900_in_time_scale(&self, time_scale: TimeScale) -> Duration {
self.to_duration_since_j1900_in_time_scale(time_scale)
}
/*
ChristopherRabotin marked this conversation as resolved.
Show resolved Hide resolved
#[must_use]
#[deprecated(
note = "Prefix for this function is now `to_` instead of `as_`.",
since = "3.5.0"
)]
pub fn as_duration_since_j1900_in_time_scale(&self, time_scale: TimeScale) -> Duration {
self.to_duration_since_j1900_in_time_scale(time_scale)
}
*/

#[must_use]
#[deprecated(
Expand All @@ -96,14 +98,16 @@ impl Epoch {
self.to_tai_seconds()
}

#[must_use]
#[deprecated(
note = "Prefix for this function is now `to_` instead of `as_`.",
since = "3.5.0"
)]
pub const fn as_tai_duration(&self) -> Duration {
self.to_tai_duration()
}
/*
#[must_use]
#[deprecated(
note = "Prefix for this function is now `to_` instead of `as_`.",
since = "3.5.0"
)]
pub const fn as_tai_duration(&self) -> Duration {
self.to_tai_duration()
}
*/

#[must_use]
#[deprecated(
Expand Down
7 changes: 4 additions & 3 deletions src/efmt/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ impl Formatter {
}
}

pub fn in_time_scale(epoch: Epoch, format: Format, time_scale: TimeScale) -> Self {
Self::new(epoch.in_time_scale(time_scale), format)
pub fn to_time_scale(epoch: Epoch, format: Format, time_scale: TimeScale) -> Self {
Self::new(epoch.to_time_scale(time_scale), format)
}

pub fn set_timezone(&mut self, offset: Duration) {
Expand All @@ -127,7 +127,8 @@ impl fmt::Display for Formatter {

if self.format.need_gregorian() {
// This is a specific branch so we don't recompute the gregorian information for each token.
let (y, mm, dd, hh, min, s, nanos) = Epoch::compute_gregorian(self.epoch.to_duration());
let (y, mm, dd, hh, min, s, nanos) =
Epoch::compute_gregorian(self.epoch.to_duration_in_time_scale(TimeScale::TAI));
// And format.
for (i, maybe_item) in self
.format
Expand Down
Loading