Class Time
Defined in File Time.h
Class Documentation
-
class Time
Provides functionality for time stamps and conversion between different formats.
Public Functions
-
explicit Time(const char *timestamp)
Construct a new Time object from a timestamp.
- Parameters
timestamp – timestamp in form YYYY-MM-DD-HH:MM:SS +tz
-
explicit Time(time_t timestamp)
Construct a new Time object from a time epoch.
- Parameters
timestamp – timestamp to initalize with
-
void set_time(const std::string ×tamp)
Set the time of the object.
- Parameters
timestamp – in form YYYY-MM-DD-HH:MM:SS +tz
-
inline void set_time(time_t timestamp)
Set the time of the object.
- Parameters
timestamp – in form YYYY-MM-DD-HH:MM:SS +tz
-
inline auto get_time() -> time_t
Return the time of the object.
- Returns
time_t epoch to return
-
void set_fractional_time(double seconds)
Set the fractional seconds part of the timestamp.
- Parameters
seconds – of the fractional part of the timestamp
-
void set_fractional_time(uint64_t attoseconds)
Set the fractional seconds part of the timestamp.
- Parameters
attoseconds – of the fractional part of the timestamp
-
auto get_fractional_time() -> double
Get the fractional time of the timestamp in seconds.
- Returns
double fractional time in seconds
-
auto get_fractional_time_attoseconds() -> uint64_t
Get the fractional time of the timestamp in attoseconds.
- Returns
double fractional time in attoseconds
-
inline auto get_mjd_day() -> int
Return the timestamp as a Modified Julian Day The return value is an integer day.
- Returns
int
-
auto get_gm_year() -> int
Return the year of the object.
- Returns
int
-
auto get_gm_month() -> int
Return the month of the object.
- Returns
int
-
inline void add_seconds(unsigned n)
Add the specified seconds to the object.
- Parameters
n – number of seconds to add
-
inline void sub_seconds(unsigned n)
Subtract the specified seconds from the object.
- Parameters
n – number of seconds to subtract
-
auto get_localtime() -> std::string
Return a string representation of the timestamp in the local time zone.
- Returns
std::string localtime timestamp in YYYY-MM-DD-HH:MM:SS format
-
auto get_gmtime() -> std::string
Return a string representation of the timestamp in the UTC time zone.
- Returns
std::string gmtime timestamp in YYYY-MM-DD-HH:MM:SS format
Public Static Functions
-
static auto mjd2utctm(double mjd) -> time_t
Convert an MJD to the time_t.
- Parameters
mjd –
- Returns
time_t
-
static auto format_localtime(time_t e) -> std::string
Convert the provided epoch into a string timestamp in the local time zone.
- Parameters
e – epoch to convert
- Returns
std::string timestamp in local time zone
-
static auto format_gmtime(time_t e) -> std::string
Converted the provided epoch into a string timestamp in the UTC time zone.
- Parameters
e – epoch to convert
- Returns
std::string timestamp in the UTC time zone
-
explicit Time(const char *timestamp)