41#include "../ioutils/stringUtils.hpp"
42#include "../astro/sofa.hpp"
64template <
typename typeT =
double, clock
id_t clk_
id = CLOCK_REALTIME>
67 clock_gettime( clk_id, &tsp );
69 return ( (typeT)tsp.tv_sec ) + ( (typeT)tsp.tv_nsec ) / 1e9;
74double get_curr_time<double, CLOCK_REALTIME>( timespec &tsp );
92template <
typename typeT =
double, clock
id_t clk_
id = CLOCK_REALTIME>
96 return get_curr_time<typeT, clk_id>( tsp );
101double get_curr_time<double, CLOCK_REALTIME>();
110void sleep(
unsigned sec );
161template <
typename floatT>
165 const std::string &hmsstr
173 en = hmsstr.find(
':', st );
175 h = ioutils::convertFromString<floatT>( hmsstr.substr( st, en - st ).c_str() );
178 if( std::signbit( h ) )
183 en = hmsstr.find(
':', st );
185 m = sgn * ioutils::convertFromString<floatT>( hmsstr.substr( st, en - st ) );
189 s = sgn * ioutils::convertFromString<floatT>( hmsstr.substr( st, hmsstr.length() - st ).c_str() );
230 const std::string &fdate
255template <
typename timeT>
311 const double &timeIn,
439template <
typename arithT>
444 ts.tv_sec += floor( add );
446 ts.tv_nsec += ( add - floor( add ) ) * 1e9;
448 if( ts.tv_nsec >= 1e9 )
461template <
typename arithT>
466 ts.tv_sec -= floor( sub );
468 ts.tv_nsec -= ( sub - floor( sub ) ) * 1e9;
void nanoSleep(unsigned nsec)
Sleep for a specified period in nanoseconds.
void sleep(unsigned sec)
Sleep for a specified period in seconds.
void milliSleep(unsigned msec)
Sleep for a specified period in milliseconds.
void microSleep(unsigned usec)
Sleep for a specified period in microseconds.
bool operator<(timespec const &tsL, timespec const &tsR)
Timespec comparison operator < (see caveats)
bool operator==(timespec const &tsL, timespec const &tsR)
Timespec comparison operator == (see caveats)
bool operator>(timespec const &tsL, timespec const &tsR)
Timespec comparison operator > (see caveats)
bool operator>=(timespec const &tsL, timespec const &tsR)
Timespec comparison operator >= (see caveats)
bool operator<=(timespec const &tsL, timespec const &tsR)
Timespec comparison operator <= (see caveats)
int 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.
std::string ISO8601DateTimeStr(const timeT &timeIn, int timeZone=0)
Get a date-time string in ISO 8601 format.
std::string ISO8601DateTimeStrMJD(const double &timeIn, int timeZone=0)
Get a date-time string in ISO 8601 format for an MJD.
int timespecUTC2TAIMJD(double &djm, double &djmf, const timespec &tsp, tm *tm0)
Convert a UTC timespec to TAI modified Julian date.
std::string ISO8601DateTimeStr< timespec >(const timespec &timeIn, int timeZone)
Get a date-time string in ISO 8601 format for timespec.
void timespecAddNsec(timespec &ts, unsigned nsec)
Adds a time offset to an existing timespec.
void parse_hms(floatT &h, floatT &m, floatT &s, const std::string &hmsstr)
typeT get_curr_time()
Get the current system time in seconds.
int timeStamp(std::string &tstamp, timespec &ts)
Get a timestamp string in the form YYYYMMDDHHMMSS.SSSSSSSSS.
double Cal2mjd(int yr, int mon, int day, int hr, int min, double sec)
Converts a Gregorian calendar date into modified Julian date (MJD).
double 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)
std::string ISO8601DateTimeStr< time_t >(const time_t &timeIn, int timeZone)
Get a date-time string in ISO 8601 format for time_t.
timespec operator-(timespec ts, arithT sub)
Subtract an amount of time specified in seconds from a timespec.
timespec operator+(timespec ts, arithT add)
Add an amount of time specified in seconds to a timespec.
timespec meanTimespec(timespec ts1, timespec ts2)
Calculate the mean time of two times given by timespecs.