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

Legible instants #3034

Merged
merged 12 commits into from
Jul 5, 2021
Merged

Legible instants #3034

merged 12 commits into from
Jul 5, 2021

Conversation

eggrobin
Copy link
Member

@eggrobin eggrobin commented Jun 19, 2021

This will be used in operator<<(std::ostream&, Instant) in a future PR.

auto const date = TTDay(t);
Instant const beginning_of_day = DateTimeAsTT(DateTime::BeginningOfDay(date));
// Close to J2000, Sterbenz’s lemma can fail to apply to this subtraction. We
// compute it exactly and round by hand.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an unfortunate property. I wish we had taken, e.g., the origin of MJD as our zero. (Nobody flies rockets in 1858.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JD0 would be the standard approach if the origin is really annoying, but I don’t think this really is a problem except for this kind of correct rounding or round-tripping trickery, and having the origin in the middle of the timespan we care about means we have better resolution, which seems like it should be more broadly useful.

quantities::Time const time_of_day_rounded_down =
time_of_day.error >= 0 * Second
? time_of_day.value
: std::bit_cast<double>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment these bit-casting.

eggrobin added a commit to eggrobin/Principia that referenced this pull request Jun 27, 2021
@eggrobin eggrobin mentioned this pull request Jun 27, 2021
@eggrobin eggrobin marked this pull request as draft June 27, 2021 13:35
@eggrobin eggrobin marked this pull request as ready for review July 4, 2021 16:22
@pleroy pleroy added the LGTM label Jul 4, 2021
@eggrobin eggrobin merged commit 684e0ed into mockingbirdnest:master Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants