Skip to content

Commit

Permalink
working on UTC dates
Browse files Browse the repository at this point in the history
  • Loading branch information
xanthospap committed Nov 2, 2023
1 parent 19b9703 commit 0ef23e9
Show file tree
Hide file tree
Showing 18 changed files with 623 additions and 269 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,23 @@ It uses the *Julian year* of exactly 365.25 days, and the *TT* time scale;
Julian epoch 2000.0 is defined to be 2000 January 1.5 (i.e. 2000 January 1d 12h),
which is JD 2,451,545.0 (i.e. `dso::J2000_JD`) or MJD 51,544.5 (i.e. `dso::J2000_MJD`).
Julian epoch is usually denoted as *“J2000.0”*.

### Precision

**Transforming from `datetime<T>` to `TwoPartDate`s**

Transforming from a `datetime<nanoseconds>` instance to an instance of type
`TwoPartDate` preserves a precision better than 2e-2 nanoseconds. This is verified
by running the test program (unit_tests/tpdates1.cpp)[unit_tests/tpdates1.cpp]

Transforming from a `datetime<microseconds>` instance to an instance of type
`TwoPartDate` preserves a precision better than 2e-5 microseconds. This is verified
by running the test program (unit_tests/tpdates2.cpp)[unit_tests/tpdates2.cpp]

Transforming from a `datetime<milliseconds>` instance to an instance of type
`TwoPartDate` preserves a precision better than 2e-8 milliseconds. This is verified
by running the test program (unit_tests/tpdates3.cpp)[unit_tests/tpdates3.cpp]

Transforming from a `datetime<seconds>` instance to an instance of type
`TwoPartDate` preserves a precision better than 2e-12 seconds. This is verified
by running the test program (unit_tests/tpdates4.cpp)[unit_tests/tpdates4.cpp]
2 changes: 1 addition & 1 deletion src/cdatetime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ constexpr const double J2000_MJD = 51544.5e0;
/** Julian Date of Modified Julian Date zero. */
constexpr const double MJD0_JD = 2400000.5e0;

/** TT minus TAI in seconds. */
/** TT minus TAI in [sec] */
constexpr const double TT_MINUS_TAI = 32.184e0;

} /* namespace dso */
Expand Down
1 change: 0 additions & 1 deletion src/datetime_tops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ template <typename S, typename T = double,
#endif
T to_fractional_days(S nsec) noexcept {
const T sec = static_cast<T>(nsec.__member_ref__());
//return sec / static_cast<T>(S::max_in_day);
return sec / S::max_in_day;
}

Expand Down
2 changes: 1 addition & 1 deletion src/dtfund.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,6 @@ class seconds {
return m_sec;
}

private:
/** Cast to any arithmetic type. */
#if __cplusplus >= 202002L
template <typename T>
Expand All @@ -1228,6 +1227,7 @@ class seconds {
return static_cast<T>(m_sec);
}

private:
/** The seconds as underlying type. */
underlying_type m_sec;
}; /* seconds */
Expand Down
2 changes: 2 additions & 0 deletions src/tai2utc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dso::TwoPartDate dso::tai2utc(const dso::TwoPartDate &dtai) noexcept {
}
*/

/*
double dso::tai2utc(const dso::datetime<dso::nanoseconds> &tai,
dso::modified_julian_day &mjd) noexcept {
// calendar date to MJD
Expand Down Expand Up @@ -66,3 +67,4 @@ double dso::tai2utc(const dso::datetime<dso::nanoseconds> &tai,
#endif
return static_cast<double>(sec_in_day) / static_cast<double>(max_sec_in_day);
}
*/
Loading

0 comments on commit 0ef23e9

Please sign in to comment.