GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GTime Class Reference

Time class. More...

#include <GTime.hpp>

Inheritance diagram for GTime:
GBase

Public Member Functions

 GTime (void)
 Void constructor. More...
 
 GTime (const GTime &time)
 Copy constructor. More...
 
 GTime (const double &time, const std::string &unit="sec")
 Time constructor. More...
 
 GTime (const double &time, const GTimeReference &ref)
 Time constructor. More...
 
 GTime (const std::string &time, const GTimeReference &ref)
 Time constructor. More...
 
 GTime (const std::string &time)
 Time constructor. More...
 
virtual ~GTime (void)
 Destructor. More...
 
GTimeoperator= (const GTime &time)
 Assignment operator. More...
 
GTimeoperator+= (const double &seconds)
 Add seconds to time. More...
 
GTimeoperator-= (const double &seconds)
 Subtract seconds from time. More...
 
void clear (void)
 Clear time. More...
 
GTimeclone (void) const
 Clone time. More...
 
std::string classname (void) const
 Return class name. More...
 
double jd (void) const
 Return time in Julian Days (TT) More...
 
double jd (const std::string &timesys) const
 Return time in Julian Days for time system. More...
 
double mjd (void) const
 Return time in Modified Julian Days (TT) More...
 
double mjd (const std::string &timesys) const
 Return time in Modified Julian Days for time system. More...
 
const double & secs (void) const
 Return time in seconds in native reference (TT) More...
 
double secs (const std::string &timesys) const
 Return time in seconds in native reference for time system. More...
 
double days (void) const
 Return time in days in native reference (TT) More...
 
double days (const std::string &timesys) const
 Return time in days in native reference for time system. More...
 
double julian_epoch (void) const
 Return Julian epoch in native reference (TT) More...
 
double julian_epoch (const std::string &timesys) const
 Return Julian epoch in native reference for time system. More...
 
std::string utc (const int &precision=0) const
 Return time as string in UTC time system. More...
 
double gmst (void) const
 Return Greenwich mean sidereal time in hours in a day. More...
 
double gast (void) const
 Return Greenwich apparent sidereal time in hours in a day. More...
 
double lmst (const double &geolon) const
 Return local mean sidereal time in hours in a day. More...
 
double last (const double &geolon) const
 Return local apparent sidereal time in hours in a day. More...
 
double leap_seconds (void) const
 Return number of leap seconds for current time. More...
 
double utc2tt (void) const
 Return time difference between UTC and TT (seconds) More...
 
double convert (const GTimeReference &ref) const
 Return time in specified reference. More...
 
void jd (const double &time)
 Set time in Julian Days in native reference (TT) More...
 
void jd (const double &time, const std::string &timesys)
 Set time in Julian Days in native reference for time system. More...
 
void mjd (const double &time)
 Set time in Modified Julian Days in native reference (TT) More...
 
void mjd (const double &time, const std::string &timesys)
 Set time in Modified Julian Days in native reference for time system. More...
 
void secs (const double &seconds)
 Set time in seconds in native reference (TT) More...
 
void secs (const double &seconds, const std::string &timesys)
 Set time in seconds in native reference for time system. More...
 
void days (const double &days)
 Set time in days in native reference (TT) More...
 
void days (const double &days, const std::string &timesys)
 Set time in days in native reference for time system. More...
 
void utc (const std::string &time)
 Set time as string in UTC time system. More...
 
void set (const double &time, const GTimeReference &ref)
 Set time given in specified reference. More...
 
void set (const std::string &time, const GTimeReference &ref)
 Set time from string. More...
 
void set (const std::string &time)
 Set time for string for native time reference system. More...
 
void now (void)
 Set time to current time. More...
 
GTimeReference reference (void) const
 Returns native time reference. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print time. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GTime &time)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
double leap_seconds (const double &mjd) const
 Returns number of leap seconds for a given MJD. More...
 
bool is_leap_year (const int &year) const
 Signals if year is a leap year. More...
 
int days_in_year (const int &year) const
 Returns number of days in year. More...
 
double extract_timeval (const std::string &time) const
 Extract time value from time string. More...
 
std::string extract_timesys (const std::string &time) const
 Extract time system from time string. More...
 

Protected Attributes

double m_time
 Time in seconds in native reference (TT) More...
 

Friends

GTime operator+ (const GTime &time, const double &seconds)
 Add seconds to time. More...
 
GTime operator+ (const double &seconds, const GTime &time)
 Add seconds to time. More...
 
GTime operator- (const GTime &time, const double &seconds)
 Subtract seconds from time. More...
 
double operator- (const GTime &a, const GTime &b)
 Subtract times. More...
 
bool operator== (const GTime &a, const GTime &b)
 Check if times are equal. More...
 
bool operator!= (const GTime &a, const GTime &b)
 Check if times are not equal. More...
 
bool operator< (const GTime &a, const GTime &b)
 Check if time is smaller than other time. More...
 
bool operator<= (const GTime &a, const GTime &b)
 Check if time is smaller than or equal to other time. More...
 
bool operator> (const GTime &a, const GTime &b)
 Check if time is larger than other time. More...
 
bool operator>= (const GTime &a, const GTime &b)
 Check if time is larger than or equal to other time. More...
 

Detailed Description

Time class.

The GTime class stores a time value in seconds in a GammaLib native time reference system. The GammaLib native time reference (i.e. time=0) is defined as

                January 1, 2010, 00:00:00 (TT)

The time system is Terrestrial Time (TT). With respect to Coordinated Universal Time (UTC), TT time is greater than UTC time by 66.184 sec at January 1, 2010, 00:00:00. The difference is due to the introduction of leap seconds that synchronize TT with the Earth rotation (UTC).

Definition at line 55 of file GTime.hpp.

Constructor & Destructor Documentation

GTime::GTime ( void  )

Void constructor.

Definition at line 67 of file GTime.cpp.

References init_members().

Referenced by clone().

GTime::GTime ( const GTime time)

Copy constructor.

Parameters
[in]timeTime.

Definition at line 82 of file GTime.cpp.

References copy_members(), and init_members().

GTime::GTime ( const double &  time,
const std::string &  unit = "sec" 
)

Time constructor.

Parameters
[in]timeTime value in TT (seconds or days).
[in]unitTime unit string.
Exceptions
GException::invalid_argumentInvalid time unit specified.

Constructs a GTime object by setting the time in the native reference in the TT time system in units of seconds (default) or days.

Definition at line 107 of file GTime.cpp.

References days(), G_CONSTRUCT, init_members(), secs(), and gammalib::tolower().

GTime::GTime ( const double &  time,
const GTimeReference ref 
)

Time constructor.

Parameters
[in]timeTime in given reference system.
[in]refReference system.

Constructs a GTime object by setting the time to a value given in a specific reference system.

Definition at line 141 of file GTime.cpp.

References init_members(), and set().

GTime::GTime ( const std::string &  time,
const GTimeReference ref 
)

Time constructor.

Parameters
[in]timeTime string in given reference system.
[in]refReference system.

Constructs a GTime object by setting the time to a string value. See the set(std::string&, GTimeReference&) method for valid time strings.

Definition at line 163 of file GTime.cpp.

References init_members(), and set().

GTime::GTime ( const std::string &  time)
explicit

Time constructor.

Parameters
[in]timeTime string.

Constructs a GTime object by setting the time to a string value. See the set(const std::string& time) method for valid time strings.

Definition at line 184 of file GTime.cpp.

References init_members(), and set().

GTime::~GTime ( void  )
virtual

Destructor.

Definition at line 200 of file GTime.cpp.

References free_members().

Member Function Documentation

std::string GTime::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GTime").

Implements GBase.

Definition at line 144 of file GTime.hpp.

GTime * GTime::clone ( void  ) const
virtual

Clone time.

Returns
Pointer to deep copy of time.

Implements GBase.

Definition at line 270 of file GTime.cpp.

References GTime().

double GTime::convert ( const GTimeReference ref) const

Return time in specified reference.

Returns
Time in specified reference.

Convert the time from the native reference system into the specified reference system.

Definition at line 698 of file GTime.cpp.

References leap_seconds(), m_time, mjd(), mjd_ref, GTimeReference::mjdref(), gammalib::sec2day, gammalib::sec_in_day, gammalib::tai2tt, GTimeReference::timesys(), gammalib::toupper(), and GTimeReference::unitseconds().

Referenced by GModelTemporalLightCurve::eval(), GGti::extend(), GModelTemporalLightCurve::print(), GGti::write(), GCTACubeExposure::write_attributes(), and GCTAObservation::write_attributes().

void GTime::copy_members ( const GTime time)
protected

Copy class members.

Parameters
[in]timeTime.

Definition at line 1230 of file GTime.cpp.

References m_time.

Referenced by GTime(), and operator=().

double GTime::days ( void  ) const

Return time in days in native reference (TT)

Returns
Time in native reference (days).

Definition at line 400 of file GTime.cpp.

References m_time, and gammalib::sec2day.

Referenced by days_in_year(), gast(), gmst(), GTime(), and utc().

double GTime::days ( const std::string &  timesys) const

Return time in days in native reference for time system.

Parameters
[in]timesysTime system (one of "TT", "TAI", "UTC")
Returns
Time in native reference (days).

Definition at line 413 of file GTime.cpp.

References gammalib::sec2day, and secs().

void GTime::days ( const double &  days)

Set time in days in native reference (TT)

Parameters
[in]daysTime (TT) (days).

Definition at line 857 of file GTime.cpp.

References m_time, and gammalib::sec_in_day.

void GTime::days ( const double &  days,
const std::string &  timesys 
)

Set time in days in native reference for time system.

Parameters
[in]daysTime (TT) (days).
[in]timesysTime system (one of "TT", "TAI", "UTC")

Definition at line 873 of file GTime.cpp.

References gammalib::sec_in_day, and secs().

int GTime::days_in_year ( const int &  year) const
inlineprotected

Returns number of days in year.

Parameters
[in]yearYear (four digits integer).
Returns
Number of days in year.

Definition at line 225 of file GTime.hpp.

References days(), and is_leap_year().

Referenced by utc().

std::string GTime::extract_timesys ( const std::string &  time) const
protected

Extract time system from time string.

Parameters
[in]timeTime string.
Returns
Time system.

Extracts the time system from a time string. Valid time systems are:

"(TT)" (TT system)
"(UTC)" (UTC system)
"(TAI)" (TAI system)

If no time system is found a blank string is returned.

Definition at line 1371 of file GTime.cpp.

References gammalib::str(), gammalib::strip_whitespace(), and gammalib::toupper().

Referenced by set().

double GTime::extract_timeval ( const std::string &  time) const
protected

Extract time value from time string.

Parameters
[in]timeTime string.
Returns
Time value.

Extracts the time value from a time string. The method strips any prefix such as "MJD" or "JD" and any suffix starting with a left parentheses "(" and converts the remainder into a double precision value.

Definition at line 1329 of file GTime.cpp.

References gammalib::todouble().

Referenced by set().

void GTime::free_members ( void  )
protected

Delete class members.

Definition at line 1243 of file GTime.cpp.

Referenced by clear(), operator=(), and ~GTime().

double GTime::gast ( void  ) const

Return Greenwich apparent sidereal time in hours in a day.

Returns
Greenwich apparent sidereal time (hours).

See http://aa.usno.navy.mil/faq/docs/GAST.php

Definition at line 616 of file GTime.cpp.

References cos(), days(), gammalib::deg2rad, gmst(), and sin().

Referenced by last().

double GTime::gmst ( void  ) const

Return Greenwich mean sidereal time in hours in a day.

Returns
Greenwich mean sidereal time (hours).

See http://aa.usno.navy.mil/faq/docs/GAST.php

Definition at line 593 of file GTime.cpp.

References days().

Referenced by gast(), and lmst().

void GTime::init_members ( void  )
protected

Initialise class members.

Definition at line 1215 of file GTime.cpp.

References m_time.

Referenced by clear(), GTime(), and operator=().

bool GTime::is_leap_year ( const int &  year) const
inlineprotected

Signals if year is a leap year.

Parameters
[in]yearYear (four digits integer).
Returns
True if year is a leap year.

Definition at line 210 of file GTime.hpp.

Referenced by days_in_year(), and utc().

double GTime::jd ( void  ) const

Return time in Julian Days (TT)

Returns
Time in Julian Days (TT) (days).

Returns the time in Julian Days (JD) in the Terrestrial Time (TT) system.

Definition at line 284 of file GTime.cpp.

References jd_ref, m_time, and gammalib::sec2day.

Referenced by GEphemerides::ephemeris(), jd(), julian_epoch(), GEphemerides::load(), GSkyDir::moon(), set(), and GSkyDir::sun().

double GTime::jd ( const std::string &  timesys) const

Return time in Julian Days for time system.

Parameters
[in]timesysTime system (one of "TT", "TAI", "UTC")
Returns
Time in Julian Days (days).

Returns the time in Julian Days (JD) for the specified time system.

Definition at line 302 of file GTime.cpp.

References jd(), jd_ref, gammalib::sec2day, and secs().

void GTime::jd ( const double &  time)

Set time in Julian Days in native reference (TT)

Parameters
[in]timeTime in Julian Days (TT) (days).

Definition at line 750 of file GTime.cpp.

References jd_ref, m_time, and gammalib::sec_in_day.

void GTime::jd ( const double &  time,
const std::string &  timesys 
)

Set time in Julian Days in native reference for time system.

Parameters
[in]timeTime in Julian Days (days).
[in]timesysTime system (one of "TT", "TAI", "UTC")

Definition at line 766 of file GTime.cpp.

References jd_ref, gammalib::sec_in_day, and secs().

double GTime::julian_epoch ( void  ) const

Return Julian epoch in native reference (TT)

Returns
Julian epoch (years).

Definition at line 425 of file GTime.cpp.

References jd().

Referenced by julian_epoch(), GSkyDir::moon(), and GSkyDir::sun().

double GTime::julian_epoch ( const std::string &  timesys) const

Return Julian epoch in native reference for time system.

Parameters
[in]timesysTime system (one of "TT", "TAI", "UTC")
Returns
Julian epoch (years).

Definition at line 441 of file GTime.cpp.

References jd(), and julian_epoch().

double GTime::last ( const double &  geolon) const

Return local apparent sidereal time in hours in a day.

Parameters
[in]geolonGeographic longitude West of Greenwich (degrees).
Returns
Local apparent sidereal time (hours).

See http://aa.usno.navy.mil/faq/docs/GAST.php

Definition at line 677 of file GTime.cpp.

References gast().

double GTime::leap_seconds ( void  ) const
inline

Return number of leap seconds for current time.

Returns
Number of leap seconds for current time (seconds).

Definition at line 181 of file GTime.hpp.

References mjd().

Referenced by convert(), secs(), set(), utc(), and utc2tt().

double GTime::leap_seconds ( const double &  mjd) const
protected

Returns number of leap seconds for a given MJD.

Parameters
[in]mjdModified Julian Day in UTC time system.
Returns
Number of lead seconds.

Return the number of leap seconds for a given MJD specified in the UTC time system. This method returns valid number of leap seconds for the years 1972-2017.

See http://www.nist.gov/pml/div688/grp50/leapsecond.cfm for a table of leap seconds.

Definition at line 1263 of file GTime.cpp.

double GTime::lmst ( const double &  geolon) const

Return local mean sidereal time in hours in a day.

Parameters
[in]geolonGeographic longitude West of Greenwich (degrees).
Returns
Local mean sidereal time (hours).

See http://aa.usno.navy.mil/faq/docs/GAST.php

Definition at line 656 of file GTime.cpp.

References gmst().

double GTime::mjd ( void  ) const

Return time in Modified Julian Days (TT)

Returns
Time in Modified Julian Days (TT) (days).

Returns the time in Modified Julian Days (MJD) in the Terrestrial Time (TT) system.

Definition at line 320 of file GTime.cpp.

References m_time, mjd_ref, and gammalib::sec2day.

Referenced by gammalib::com_tics(), gammalib::com_time(), gammalib::com_tjd(), convert(), GPulsar::ephemeris(), leap_seconds(), GPulsar::load_fermi(), GPulsar::load_integral(), GPulsar::load_parfile(), GPulsar::load_psrtime(), mjd(), GModelTemporalPhaseCurve::mjd(), GCOMOad::print(), GCOMBvc::print(), GEphemerides::print(), GCOMTim::print(), GPulsar::print(), GCOMHkd::print(), secs(), set(), gammalib::spi_ijd2time(), and utc().

double GTime::mjd ( const std::string &  timesys) const

Return time in Modified Julian Days for time system.

Parameters
[in]timesysTime system (one of "TT", "TAI", "UTC")
Returns
Time in Modified Julian Days (days).

Returns the time in Modified Julian Days (JD) for the specified time system.

Definition at line 339 of file GTime.cpp.

References mjd(), mjd_ref, gammalib::sec2day, and secs().

void GTime::mjd ( const double &  time)

Set time in Modified Julian Days in native reference (TT)

Parameters
[in]timeTime in Modified Julian Days (TT) (days).

Definition at line 784 of file GTime.cpp.

References m_time, mjd_ref, and gammalib::sec_in_day.

void GTime::mjd ( const double &  time,
const std::string &  timesys 
)

Set time in Modified Julian Days in native reference for time system.

Parameters
[in]timeTime in Modified Julian Days (days).
[in]timesysTime system (one of "TT", "TAI", "UTC")

Definition at line 801 of file GTime.cpp.

References mjd_ref, gammalib::sec_in_day, and secs().

void GTime::now ( void  )

Set time to current time.

Sets time to current time.

Definition at line 1126 of file GTime.cpp.

References utc().

Referenced by GDaemon::alive(), GDaemon::create_xml(), GDaemon::recover_valid_xml(), GDaemon::update_dates(), and GDaemon::write_heartbeat().

GTime & GTime::operator+= ( const double &  seconds)
inline

Add seconds to time.

Parameters
[in]secondsSeconds.
Returns
Time.

Adds seconds to the time.

Definition at line 241 of file GTime.hpp.

References m_time.

GTime & GTime::operator-= ( const double &  seconds)
inline

Subtract seconds from time.

Parameters
[in]secondsSeconds.
Returns
Time.

Subtracts seconds from the time.

Definition at line 257 of file GTime.hpp.

References m_time.

GTime & GTime::operator= ( const GTime time)

Assignment operator.

Parameters
[in]timeTime.
Returns
Time.

Definition at line 222 of file GTime.cpp.

References copy_members(), free_members(), and init_members().

std::string GTime::print ( const GChatter chatter = NORMAL) const
virtual

Print time.

Parameters
[in]chatterChattiness.
Returns
String containing time in seconds in native reference.

Prints time in seconds in the native reference.

Implements GBase.

Definition at line 1188 of file GTime.cpp.

References m_time, SILENT, and gammalib::str().

Referenced by GModelSpatialRadialGauss::eval(), GModelSpatialRadialGeneralGauss::eval(), GModelSpectralPlaw::eval(), GGti::insert_gti(), GModelSpectralExpPlaw::mc(), GModelSpectralSuperExpPlaw::mc(), GModelSpectralExpInvPlaw::mc(), GCOMEventAtom::print(), GLATEventAtom::print(), GCTAEventAtom::print(), GPhoton::print(), GSource::print(), GCOMEventCube::print(), and GGti::reduce().

GTimeReference GTime::reference ( void  ) const

Returns native time reference.

Returns
Native time reference.

Returns the native GammaLib time reference. The GammaLib native time reference (i.e. time=0) is defined as January 1, 2010, 00:00:00 (TT). The time system is Terrestrial Time (TT). Time is stored in seconds.

Definition at line 1170 of file GTime.cpp.

References mjd_ref.

Referenced by GGti::init_members(), set(), and GApplicationPar::time().

const double & GTime::secs ( void  ) const
inline
double GTime::secs ( const std::string &  timesys) const

Return time in seconds in native reference for time system.

Parameters
[in]timesysTime system (one of "TT", "TAI", "UTC")
Returns
Time (seconds).

Definition at line 355 of file GTime.cpp.

References G_SECS_GET, leap_seconds(), m_time, mjd(), mjd_ref, gammalib::sec2day, and gammalib::tai2tt.

void GTime::secs ( const double &  seconds)
inline

Set time in seconds in native reference (TT)

Parameters
[in]secondsTime in native reference (seconds).

Definition at line 168 of file GTime.hpp.

References m_time.

void GTime::secs ( const double &  seconds,
const std::string &  timesys 
)

Set time in seconds in native reference for time system.

Parameters
[in]secondsTime in native reference (seconds).
[in]timesysTime system (one of "TT", "TAI", "UTC")

Definition at line 820 of file GTime.cpp.

References G_SECS_SET, leap_seconds(), m_time, mjd(), mjd_ref, gammalib::sec2day, and gammalib::tai2tt.

void GTime::set ( const double &  time,
const GTimeReference ref 
)

Set time given in specified reference.

Parameters
[in]timeTime in given reference system.
[in]refReference system.

Set the time to a value given in a specific reference system.

Definition at line 1005 of file GTime.cpp.

References leap_seconds(), m_time, mjd(), mjd_ref, GTimeReference::mjdref(), gammalib::sec_in_day, gammalib::tai2tt, GTimeReference::timesys(), gammalib::toupper(), and GTimeReference::unitseconds().

Referenced by GGti::extend(), GTime(), GModelTemporalLightCurve::load_nodes(), GGti::read(), GLATEventList::read_events(), and set().

void GTime::set ( const std::string &  time,
const GTimeReference ref 
)

Set time from string.

Parameters
[in]timeTime string.
[in]refReference system.

Sets the time from a string for a given reference system. The following strings are valid:

"2016-10-05T15:08:56" (UTC string)
"1800.0" (MET seconds in specified reference system)
"1800.0 (TT)" (MET seconds in specified reference, TT system)
"1800.0 (UTC)" (MET seconds in specified reference, UTC time system)
"1800.0 (TAI)" (MET seconds in specified reference, TAI time system)
"MJD 54609" (Modified Julian Days, TT system)
"MJD 54609 (TT)" (Modified Julian Days, TT system)
"MJD 54609 (UTC)" (Modified Julian Days, UTC system)
"MJD 54609 (TAI)" (Modified Julian Days, TAI system)
"JD 54609" (Julian Days, TT system)
"JD 54609 (TT)" (Julian Days, TT system)
"JD 54609 (UTC)" (Julian Days, UTC system)
"JD 54609 (TAI)" (Julian Days, TAI system)

If any other string is encountered, the numerical value is interpreted as time is seconds using the TT system.

Note that the TT, UTC or TAI attributes overwrite the values contained in the specified reference system. The reference system is only used to convert MET times in seconds.

Definition at line 1065 of file GTime.cpp.

References extract_timesys(), extract_timeval(), jd(), mjd(), GTimeReference::mjdref(), set(), gammalib::str(), gammalib::strip_whitespace(), GTimeReference::timeref(), GTimeReference::timesys(), GTimeReference::timeunit(), gammalib::toupper(), and utc().

void GTime::set ( const std::string &  time)
inline

Set time for string for native time reference system.

Parameters
[in]timeTime string.

Definition at line 424 of file GTime.hpp.

References reference(), and set().

std::string GTime::utc ( const int &  precision = 0) const

Return time as string in UTC time system.

Parameters
[in]precisionDigits of precision to show in the seconds field
Returns
Time as string in UTC time system.

Returns time in the format YYYY-MM-DDThh:mm:ss(.ss...), where YYYY is a four-digit year, MM a two-digit month, DD a two-digit day of month, hh two digits of hour (0 through 23), mm two digits of minutes, and ss(.ss...) two digits of second (ISO 8601 time standard). In case that precision > 0 digits in the second after the comma will be returned.

The method is only valid for dates from year 1972 on.

Definition at line 465 of file GTime.cpp.

References days(), days_in_year(), G_UTC_GET, is_leap_year(), leap_seconds(), mjd(), gammalib::sec2day, gammalib::sec_in_day, gammalib::str(), and gammalib::tai2tt.

Referenced by GDaemon::alive(), GDaemon::create_xml(), now(), GCOMOad::print(), GCOMBvc::print(), GEphemerides::print(), GCOMTim::print(), GPulsar::print(), GCOMHkd::print(), GDaemon::recover_valid_xml(), set(), GApplicationPar::time(), GDaemon::update_dates(), GCTACubeExposure::write_attributes(), GCOMDri::write_attributes(), GCTAObservation::write_attributes(), and GDaemon::write_heartbeat().

void GTime::utc ( const std::string &  time)

Set time as string in UTC time system.

Parameters
[in]timeTime string (UTC).
Exceptions
GException::invalid_argumentInvalid time string specified.

The time has to be given in the format YYYY-MM-DDThh:mm:ss.s, where YYYY is a four-digit year, MM a two-digit month, DD a two-digit day of month, hh two digits of hour (0 through 23), mm two digits of minutes, ss two digits of second and s one or more digits representing a decimal fraction of a second (ISO 8601 time standard).

The method is only valid for dates from year 1972 on.

Definition at line 902 of file GTime.cpp.

References G_UTC, is_leap_year(), leap_seconds(), mjd(), gammalib::sec2day, gammalib::str(), and gammalib::tai2tt.

double GTime::utc2tt ( void  ) const
inline

Return time difference between UTC and TT (seconds)

Returns
Time difference between UTC and TT (seconds).

Returns the time difference between UTC and TT. The time difference is a positive number and is given by the sum of 32.184 s and the number of leap seconds.

Definition at line 197 of file GTime.hpp.

References leap_seconds(), and gammalib::tai2tt.

Referenced by GPulsar::load_psrtime().

Friends And Related Function Documentation

bool operator!= ( const GTime a,
const GTime b 
)
friend

Check if times are not equal.

Parameters
[in]aFirst time.
[in]bSecond time.
Returns
True if a is not equal to b.

Definition at line 356 of file GTime.hpp.

GTime operator+ ( const GTime time,
const double &  seconds 
)
friend

Add seconds to time.

Parameters
[in]timeTime.
[in]secondsSeconds.
Returns
Time.

Adds seconds to the time.

Definition at line 274 of file GTime.hpp.

GTime operator+ ( const double &  seconds,
const GTime time 
)
friend

Add seconds to time.

Parameters
[in]secondsSeconds.
[in]timeTime.
Returns
Time.

Adds seconds to the time.

Definition at line 292 of file GTime.hpp.

GTime operator- ( const GTime time,
const double &  seconds 
)
friend

Subtract seconds from time.

Parameters
[in]timeTime.
[in]secondsSeconds.
Returns
Time.

Subtracts seconds from the time.

Definition at line 310 of file GTime.hpp.

double operator- ( const GTime a,
const GTime b 
)
friend

Subtract times.

Parameters
[in]aFirst time.
[in]bSecond time.
Returns
Time difference in seconds.

Subtracts time b from time a and returns the difference in seconds.

Definition at line 328 of file GTime.hpp.

bool operator< ( const GTime a,
const GTime b 
)
friend

Check if time is smaller than other time.

Parameters
[in]aFirst time.
[in]bSecond time.
Returns
True if a is smaller than b.

Definition at line 370 of file GTime.hpp.

bool operator<= ( const GTime a,
const GTime b 
)
friend

Check if time is smaller than or equal to other time.

Parameters
[in]aFirst time.
[in]bSecond time.
Returns
True if a is smaller than or equal to b.

Definition at line 384 of file GTime.hpp.

bool operator== ( const GTime a,
const GTime b 
)
friend

Check if times are equal.

Parameters
[in]aFirst time.
[in]bSecond time.
Returns
True if a equals b.

Definition at line 342 of file GTime.hpp.

bool operator> ( const GTime a,
const GTime b 
)
friend

Check if time is larger than other time.

Parameters
[in]aFirst time.
[in]bSecond time.
Returns
True if a is larger than b.

Definition at line 398 of file GTime.hpp.

bool operator>= ( const GTime a,
const GTime b 
)
friend

Check if time is larger than or equal to other time.

Parameters
[in]aFirst time.
[in]bSecond time.
Returns
True if a is larger than or equal to b.

Definition at line 412 of file GTime.hpp.

Member Data Documentation

double GTime::m_time
protected

The documentation for this class was generated from the following files: