tempoch-cpp
Header-only C++ wrapper for tempoch
Loading...
Searching...
No Matches
tempoch::MJD Class Reference

Modified Julian Date wrapper (value type). More...

#include <tempoch/time.hpp>

Public Member Functions

constexpr MJD ()
 
constexpr MJD (double v)
 
constexpr double value () const
 Raw value.
 
JulianDate to_jd () const
 Convert to JD.
 
UTC to_utc () const
 Convert to UTC.
 
double operator- (const MJD &other) const
 Difference in days (this – other).
 
MJD operator+ (double days) const
 Add days.
 
bool operator== (const MJD &o) const
 
bool operator!= (const MJD &o) const
 
bool operator< (const MJD &o) const
 
bool operator<= (const MJD &o) const
 
bool operator> (const MJD &o) const
 
bool operator>= (const MJD &o) const
 

Static Public Member Functions

static MJD from_utc (const UTC &utc)
 Create from a UTC date-time.
 
static MJD from_jd (const JulianDate &jd)
 Create from a Julian Date.
 

Detailed Description

Modified Julian Date wrapper (value type).

Wraps a raw double MJD value and provides conversions to/from UTC, JD, and arithmetic operations.

auto mjd = tempoch::MJD::from_utc({2026, 7, 15});
auto jd = mjd.to_jd();
auto mjd2 = mjd + 1.0; // next day
JulianDate to_jd() const
Convert to JD.
Definition time.hpp:182
static MJD from_utc(const UTC &utc)
Create from a UTC date-time.
Definition time.hpp:166

Definition at line 158 of file time.hpp.

Constructor & Destructor Documentation

◆ MJD() [1/2]

constexpr tempoch::MJD::MJD ( )
inlineconstexpr

Definition at line 162 of file time.hpp.

Referenced by from_jd(), from_utc(), and operator+().

◆ MJD() [2/2]

constexpr tempoch::MJD::MJD ( double  v)
inlineexplicitconstexpr

Definition at line 163 of file time.hpp.

Member Function Documentation

◆ from_jd()

static MJD tempoch::MJD::from_jd ( const JulianDate jd)
inlinestatic

Create from a Julian Date.

Definition at line 174 of file time.hpp.

References MJD(), and tempoch::JulianDate::value().

◆ from_utc()

static MJD tempoch::MJD::from_utc ( const UTC utc)
inlinestatic

Create from a UTC date-time.

Definition at line 166 of file time.hpp.

References tempoch::check_status(), MJD(), and tempoch::UTC::to_c().

◆ operator!=()

bool tempoch::MJD::operator!= ( const MJD o) const
inline

Definition at line 202 of file time.hpp.

◆ operator+()

MJD tempoch::MJD::operator+ ( double  days) const
inline

Add days.

Definition at line 197 of file time.hpp.

References MJD().

◆ operator-()

double tempoch::MJD::operator- ( const MJD other) const
inline

Difference in days (this – other).

Definition at line 192 of file time.hpp.

◆ operator<()

bool tempoch::MJD::operator< ( const MJD o) const
inline

Definition at line 203 of file time.hpp.

◆ operator<=()

bool tempoch::MJD::operator<= ( const MJD o) const
inline

Definition at line 204 of file time.hpp.

◆ operator==()

bool tempoch::MJD::operator== ( const MJD o) const
inline

Definition at line 201 of file time.hpp.

◆ operator>()

bool tempoch::MJD::operator> ( const MJD o) const
inline

Definition at line 205 of file time.hpp.

◆ operator>=()

bool tempoch::MJD::operator>= ( const MJD o) const
inline

Definition at line 206 of file time.hpp.

◆ to_jd()

JulianDate tempoch::MJD::to_jd ( ) const
inline

Convert to JD.

Definition at line 182 of file time.hpp.

◆ to_utc()

UTC tempoch::MJD::to_utc ( ) const
inline

Convert to UTC.

Definition at line 185 of file time.hpp.

References tempoch::check_status(), and tempoch::UTC::from_c().

◆ value()

constexpr double tempoch::MJD::value ( ) const
inlineconstexpr

Raw value.

Definition at line 179 of file time.hpp.


The documentation for this class was generated from the following file: