COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
timelib.h File Reference

timelib include file A library providing functions for handling various types of time. More...

#include "support/configCosmos.h"
#include "support/elapsedtime.h"
#include "math/mathlib.h"
#include <cmath>
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <ctime>
#include <ratio>
Include dependency graph for timelib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  timestruc
 
struct  calstruc
 
class  DateTime
 

Macros

#define MJD_UNIX_OFFSET   40587.
 
#define JD_MJD_OFFSET   2400000.5
 
#define MJD2JD(mjd)   (double)((mjd) + JD_MJD_OFFSET)
 
#define JD2MJD(jd)   (double)((jd) - JD_MJD_OFFSET)
 
#define DAY_TO_SECONDS   86400.
 
#define SECONDS_TO_DAYS(x)   ((double)(x) / DAY_TO_SECONDS)
 
#define DAYS_TO_SECONDS(x)   ((double)(x) * DAY_TO_SECONDS)
 
#define TIME_SECS_TO_DAYS(x)   ((double)(x) / DAY_TO_SECONDS)
 
#define TIME_DAYS_TO_SECS(x)   ((double)(x) * DAY_TO_SECONDS)
 
#define TIME_SECS_SINCE_MJD(x)   ( ( (currentmjd(0.)-(x)) ) * DAY_TO_SECONDS )
 
#define TIME_UNIXs_TO_MJD(unixSecs)   ( ( (unixSecs) / DAY_TO_SECONDS ) + MJD_UNIX_OFFSET )
 
#define TIME_MJD_TO_UNIXs(mjd)   (((mjd) - MJD_UNIX_OFFSET) * DAY_TO_SECONDS)
 
#define TIME_UNIX_TV_TO_DOUBLE_SECS(x)   ( ((double)(x.tv_sec)) + ((double)(x.tv_usec) / 1000000. ) )
 
#define UPTIME   (DAY_TO_SECONDS*(currentmjd(0.)-mjd_start_time))
 

Functions

double currentmjd (double offset)
 Current UTC in Modified Julian Days. More...
 
double currentmjd ()
 
unsigned long int get_unix_time ()
 
string get_local_time ()
 
double cal2mjd (calstruc date)
 Calendar representation to Modified Julian Day - structure. More...
 
double cal2mjd (double year)
 Calendar representation YYYY.ffff to Modified Julian Day - overloaded. More...
 
double cal2mjd (int32_t year, double dayOfYear)
 Calendar representation YYYY,DDD.ffff to Modified Julian Day - overloaded. More...
 
double cal2mjd (int32_t year, int32_t month, double day)
 Calendar representation to Modified Julian Day - shortened. More...
 
double cal2mjd (int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, int32_t second, int32_t nsecond)
 Calendar representation to Modified Julian Day - full. More...
 
double gregorianToModJulianDate (int32_t year, int32_t month, int32_t day, int32_t hour, int32_t minute, double second)
 
struct timeval utc2unix (double utc)
 UTC to Unix time. More...
 
double utc2unixseconds (double utc)
 UTC to Unix time. More...
 
double utc2epsilon (double mjd)
 Nutation Epsilon value. More...
 
double utc2depsilon (double mjd)
 Nutation Delta Epsilon value. More...
 
double utc2dpsi (double mjd)
 Nutation Delta Psi value. More...
 
double utc2L (double mjd)
 Nutation L value. More...
 
double utc2Lp (double mjd)
 Nutation L prime value. More...
 
double utc2F (double mjd)
 Nutation F value. More...
 
double utc2D (double mjd)
 Nutation D value. More...
 
double utc2omega (double mjd)
 Nutation omega value. More...
 
double utc2zeta (double utc)
 Precession zeta value. More...
 
double utc2z (double utc)
 Precession z value. More...
 
double utc2era (double mjd)
 Earth Rotation Angle. More...
 
double utc2tt (double mjd)
 Convert UTC to TT. More...
 
double utc2gps (double utc)
 Convert UTC to GPS. More...
 
double utc2ut1 (double mjd)
 Convert UTC to UT1. More...
 
double utc2dut1 (double mjd)
 Calculate DUT1. More...
 
double utc2tdb (double mjd)
 Convert UTC to TDB. More...
 
double utc2gmst1982 (double mjd)
 UTC (Modified Julian Day) to GMST. More...
 
double utc2gmst2000 (double utc)
 
double utc2gast (double mjd)
 UTC to GAST. More...
 
rvector utc2nuts (double mjd)
 Nutation values. More...
 
double utc2theta (double utc)
 Precession theta value. More...
 
double utc2jcentt (double mjd)
 TT Julian Century. More...
 
double utc2jcenut1 (double mjd)
 UT1 Julian Century. More...
 
string utc2unixdate (double utc)
 Time for setting unix date. More...
 
string utc2iso8601 (double utc)
 ISO 8601 version of time. More...
 
double iso86012utc (string date)
 
double gps2utc (double gps)
 Convert GPS to UTC. More...
 
void gps2week (double gps, uint32_t &week, double &seconds)
 GPS Weeks and Seconds from GPS time. More...
 
double week2gps (uint32_t week, double seconds)
 GPS Time from GPS Week and Seconds. More...
 
double mjd2year (double mjd)
 Year from MJD. More...
 
double mjd2doy (double mjd)
 Day of Year from MJD. More...
 
calstruc mjd2cal (double mjd)
 MJD to Calendar. More...
 
int32_t mjd2ymd (double mjd, int32_t &year, int32_t &month, double &day)
 MJD to Year, Month, and Decimal Day (overloaded) More...
 
int32_t mjd2ymd (double mjd, int32_t &year, int32_t &month, double &day, double &doy)
 MJD to Year, Month, Decimal Day, and Julian Day (overloaded) More...
 
string mjdToGregorian (double mjd)
 
int32_t mjdToGregorian (double mjd, int32_t *year, int32_t *month, int32_t *day, int32_t *hour, int32_t *minute, int32_t *second)
 
string mjdToGregorianFormat (double mjd)
 
string mjdToGregorianDDMMMYYYY (double mjd)
 
string mjdToGregorianDDMmmYYYY (double mjd)
 
string mjd2iso8601 (double mjd)
 
double mjd2jd (double mjd)
 Modified Julian Day to Julian Day. More...
 
double jd2mjd (double jd)
 Julian Day to Modified Julian Day. More...
 
int32_t mjd2tlef (double mjd, string &tle)
 Convert mjd to the TLE epoch format. More...
 
double unix2utc (struct timeval unixtime)
 Unix time to UTC. More...
 
double unix2utc (double unixtime)
 Unix time to UTC. More...
 
double tt2utc (double mjd)
 Convert TT to UTC. More...
 
double tt2tdb (double mjd)
 
double julcen (double mjd)
 Julian Century. More...
 
cvector polar_motion (double mjd)
 Polar motion. More...
 
int32_t leap_seconds (double mjd)
 Leap Seconds. More...
 
double ranrm (double angle)
 
int16_t isleap (int32_t year)
 Check for Leap year. More...
 
int32_t load_iers ()
 Load IERS Polar Motion, UT1-UTC, Leap Seconds. More...
 
string seconds2DDHHMMSS (double elapsed_seconds)
 Convert Elapsed Time in Seconds to Human Readable Format (used for GPS simulator) More...
 
int32_t timed_countdown (int32_t seconds, int32_t step, string message)
 
double set_local_clock (double utc_to)
 

Detailed Description

timelib include file A library providing functions for handling various types of time.