Skip to content

Parsing of MJD and JD literals #1362

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

Merged
merged 12 commits into from
May 8, 2017
Merged

Conversation

pleroy
Copy link
Member

@pleroy pleroy commented May 7, 2017

No description provided.

operator""_Date(str, index_of(str, size, 'T')),
operator""_Time(str + index_of(str, size, 'T') + 1,
size - (index_of(str, size, 'T') + 1))).checked());
size >= 2 && str[0] == 'J' && str[1]
Copy link
Member

Choose a reason for hiding this comment

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

str[1] == 'D'

Copy link
Member

Choose a reason for hiding this comment

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

Also add a death test for that (and other formatting errors).

Copy link
Member

Choose a reason for hiding this comment

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

Still testing a character as a boolean.

operator""_Time(str + index_of(str, size, 'T') + 1,
size - (index_of(str, size, 'T') + 1))).checked());
size >= 2 && str[0] == 'J' && str[1]
? contains(str, size - 1, '.')
Copy link
Member

Choose a reason for hiding this comment

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

I think this means that the parser doesn't support something like "MJD1729.". Is that correct? In any case, please comment to specify precisely what format is allowed, as is done for ISO dates.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

TEST_F(TimeScalesTest, ModifiedJulianDate) {
EXPECT_THAT("MJD0.0"_TT, Eq("1858-11-17T00:00:00"_TT));
EXPECT_THAT("MJD55200.0000"_TT, Eq("2010-01-04T00:00:00.000"_TT));
EXPECT_THAT("MJD55200.00000142361"_TT, Eq("2010-01-04T00:00:00.123"_TT));
Copy link
Member

Choose a reason for hiding this comment

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

In this implementation, nothing prevents MJD and JD from being used with UTC, which poses problems. I would not bother with supporting the ERFA quasi-JD convention, let's simply disallow those for UTC. That also makes it well-defined to go through Time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.


// If |time()| is 24:00:00, returns an equivalent DateTime where midnight is
// expressed as 00:00:00 on the next day; otherwise, returns |*this|.
constexpr DateTime normalized_end_of_day() const;

private:
constexpr DateTime(Date date, Time time);
constexpr DateTime(Date date, Time time, bool iso);
Copy link
Member

Choose a reason for hiding this comment

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

Comment the semantics of the iso parameter/member/accessor.

operator""_Date(str, index_of(str, size, 'T')),
operator""_Time(str + index_of(str, size, 'T') + 1,
size - (index_of(str, size, 'T') + 1))).checked());
size >= 2 && str[0] == 'J' && str[1]
Copy link
Member

Choose a reason for hiding this comment

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

Still testing a character as a boolean.

@@ -84,27 +76,51 @@ class DateTime final {

constexpr Date const& date() const;
constexpr Time const& time() const;
// Returns true iff the object was constructed from an ISO 8601 string.
constexpr bool iso() const;
Copy link
Member

Choose a reason for hiding this comment

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

Or from BeginningOfDay... Really what we care about in UTC is that it's not constructed from JD or MJD, not that it's constructed from an ISO 8601 string. Switch to jd() (which also encompasses any variants, including MJD).

@eggrobin eggrobin added the LGTM label May 8, 2017
@pleroy pleroy merged commit bf23d3d into mockingbirdnest:master May 8, 2017
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