|
mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Utilities for working with time. More...
Utilities for working with time.
Definition in file timeUtils.hpp.
#include <time.h>#include <sys/time.h>#include <cmath>#include <thread>#include <chrono>#include <iostream>#include "../ioutils/stringUtils.hpp"#include "../astro/sofa.hpp"Go to the source code of this file.
Namespaces | |
| namespace | mx |
| The mxlib c++ namespace. | |
Functions | |
| template<typename typeT = double, clockid_t clk_id = CLOCK_REALTIME> | |
| typeT | mx::sys::get_curr_time (timespec &tsp) |
| Get the current system time in seconds. | |
| template<typename typeT = double, clockid_t clk_id = CLOCK_REALTIME> | |
| typeT | mx::sys::get_curr_time () |
| Get the current system time in seconds. | |
| void | mx::sys::sleep (unsigned sec) |
| Sleep for a specified period in seconds. | |
| void | mx::sys::milliSleep (unsigned msec) |
| Sleep for a specified period in milliseconds. | |
| void | mx::sys::microSleep (unsigned usec) |
| Sleep for a specified period in microseconds. | |
| void | mx::sys::nanoSleep (unsigned nsec) |
| Sleep for a specified period in nanoseconds. | |
| void | mx::sys::timespecAddNsec (timespec &ts, unsigned nsec) |
| Adds a time offset to an existing timespec. | |
| template<typename floatT > | |
| void | mx::sys::parse_hms (floatT &h, floatT &m, floatT &s, const std::string &hmsstr) |
| double | mx::sys::Cal2mjd (int yr, int mon, int day, int hr, int min, double sec) |
| Converts a Gregorian calendar date into modified Julian date (MJD). | |
| int | mx::sys::ISO8601dateBreakdown (int &yr, int &mon, int &day, int &hr, int &min, double &sec, const std::string &fdate) |
| Parse an ISO8601 date of the form "YYYY-MM-DDTHH:MM:SS.S" into the individual components. | |
| double | mx::sys::ISO8601date2mjd (const std::string &fdate) |
| Parse an ISO8601 date of the form "YYYY-MM-DDTHH:MM:SS.S" and return the modified Julian date (MJD) | |
| template<typename timeT > | |
| std::string | mx::sys::ISO8601DateTimeStr (const timeT &timeIn, int timeZone=0) |
| Get a date-time string in ISO 8601 format. | |
| template<> | |
| std::string | mx::sys::ISO8601DateTimeStr< time_t > (const time_t &timeIn, int timeZone) |
| Get a date-time string in ISO 8601 format for time_t. | |
| template<> | |
| std::string | mx::sys::ISO8601DateTimeStr< timespec > (const timespec &timeIn, int timeZone) |
| Get a date-time string in ISO 8601 format for timespec. | |
| std::string | mx::sys::ISO8601DateTimeStr (int timeZone=0) |
| Get a date-time string in ISO 8601 format for the current UTC time. | |
| std::string | mx::sys::ISO8601DateTimeStrMJD (const double &timeIn, int timeZone=0) |
| Get a date-time string in ISO 8601 format for an MJD. | |
| int | mx::sys::timeStamp (std::string &tstamp, timespec &ts) |
| Get a timestamp string in the form YYYYMMDDHHMMSS.SSSSSSSSS. | |
| int | mx::sys::timespecUTC2TAIMJD (double &djm, double &djmf, const timespec &tsp, tm *tm0) |
| Convert a UTC timespec to TAI modified Julian date. | |
| timespec | mx::sys::meanTimespec (timespec ts1, timespec ts2) |
| Calculate the mean time of two times given by timespecs. | |
| bool | mx::sys::tscomp::operator< (timespec const &tsL, timespec const &tsR) |
| Timespec comparison operator < (see caveats) | |
| bool | mx::sys::tscomp::operator> (timespec const &tsL, timespec const &tsR) |
| Timespec comparison operator > (see caveats) | |
| bool | mx::sys::tscomp::operator== (timespec const &tsL, timespec const &tsR) |
| Timespec comparison operator == (see caveats) | |
| bool | mx::sys::tscomp::operator<= (timespec const &tsL, timespec const &tsR) |
| Timespec comparison operator <= (see caveats) | |
| bool | mx::sys::tscomp::operator>= (timespec const &tsL, timespec const &tsR) |
| Timespec comparison operator >= (see caveats) | |
| template<typename arithT > | |
| timespec | mx::sys::tsop::operator+ (timespec ts, arithT add) |
| Add an amount of time specified in seconds to a timespec. | |
| template<typename arithT > | |
| timespec | mx::sys::tsop::operator- (timespec ts, arithT sub) |
| Subtract an amount of time specified in seconds from a timespec. | |
| timespec mx::sys::meanTimespec | ( | timespec | ts1, |
| timespec | ts2 | ||
| ) |
Calculate the mean time of two times given by timespecs.
| [in] | ts1 | one of the times to average |
| [in] | ts2 | the other time to average |
Definition at line 270 of file timeUtils.cpp.
References mx::sys::meanTimespec().
Referenced by mx::sys::ISO8601DateTimeStr(), and mx::sys::meanTimespec().
| timespec mx::sys::tsop::operator+ | ( | timespec | ts, |
| arithT | add | ||
| ) |
Add an amount of time specified in seconds to a timespec.
| [in] | ts | the timespec to add to |
| [in] | add | the seconds to add |
Definition at line 440 of file timeUtils.hpp.
References mx::sys::tsop::operator+().
Referenced by mx::sys::tsop::operator+().
| timespec mx::sys::tsop::operator- | ( | timespec | ts, |
| arithT | sub | ||
| ) |
Subtract an amount of time specified in seconds from a timespec.
| [in] | ts | the timespec to subtract from |
| [in] | sub | the seconds to subtract |
Definition at line 462 of file timeUtils.hpp.
References mx::sys::tsop::operator-().
Referenced by mx::sys::tsop::operator-().