ReFRACtor
|
This is a simple time class. More...
#include <fp_time.h>
Public Member Functions | |
Time () | |
Default constructor. More... | |
Time (const boost::posix_time::ptime &t) | |
Create from a boost posix time. More... | |
double | frac_day_of_year () const |
Calculate the fractional day of the year. More... | |
double | frac_year () const |
Calculate the fractional year. More... | |
double | iet_time () const |
Give time in IDPS Epoch Time (IET) time, as double (epoch 1958-01-01) More... | |
operator boost::posix_time::ptime () const | |
Convert to a boost ptime. More... | |
Time & | operator+= (double T) |
Add given number of seconds to Time. More... | |
Time & | operator-= (double T) |
Subtract given number of seconds to Time. More... | |
double | pgs_time () const |
Give time in PGS toolkit time, as a double (epoch 1993-01-01) More... | |
void | print (std::ostream &os) const |
Print to stream. More... | |
std::string | print_to_string () const |
Print to string. More... | |
std::string | to_string () const |
Convert to CCSDS format. More... | |
double | unix_time () const |
Give time in unix time, as a double (epoch 1970-01-01) More... | |
Static Public Member Functions | |
static Time | parse_time (const std::string &Time_string) |
Parse CCSDS format time (e.g., "1996-07-03T04:13:57.987654Z") More... | |
static Time | time_iet (double iet) |
Return time from given IDPS Epoch Time (IET) (epoch of 1958-01-01). More... | |
static Time | time_pgs (double pgs) |
Return time from given PGS toolkit time (epoch of 1993-01-01). More... | |
static Time | time_unix (double unix_time) |
Return time from given Unix time (epoch of 1970-01-01). More... | |
This is a simple time class.
There are a few reasonable choices for expressing time information. We could use TAI, GPS, the PGS toolkit. Each of these time system can be related to the other by a constant, since the only difference is the Epoch that time is measure against.
For simplicity, we just use the standard unix time in seconds from January 1, 1970.
This class abstracts out the representation we use for time. We supply conversions to the specific time systems for use in the cases that a specific system is needed (e.g., calling a PGS toolkit routine).
We also supply methods for converting to and from a string representation of the time. We support the standard CCSDS format (e.g., "1996-07-03T04:13:57.987654Z").
Time::Time | ( | const boost::posix_time::ptime & | t | ) |
Create from a boost posix time.
Definition at line 12 of file fp_time.cc.
double Time::frac_day_of_year | ( | ) | const |
Calculate the fractional day of the year.
This is the number of days, including the fractional part of the time of day, since midnight January 1 of the year.
Definition at line 37 of file fp_time.cc.
double Time::frac_year | ( | ) | const |
Calculate the fractional year.
This is the year plus the fractional part of it.
Definition at line 49 of file fp_time.cc.
|
inline |
Time::operator boost::posix_time::ptime | ( | ) | const |
Convert to a boost ptime.
Definition at line 23 of file fp_time.cc.
|
inline |
|
inline |
|
static |
Parse CCSDS format time (e.g., "1996-07-03T04:13:57.987654Z")
Definition at line 64 of file fp_time.cc.
|
inline |
|
inline |
|
inlineinherited |
Print to string.
This is primarily useful for SWIG wrappers to this class, e.g. a to_s method in ruby.
Definition at line 31 of file printable.h.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
std::string Time::to_string | ( | ) | const |
Convert to CCSDS format.
Definition at line 82 of file fp_time.cc.
|
inline |