EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
epicsTime Class Reference

C++ time stamp object. More...

#include <epicsTime.h>

Public Types

typedef std::runtime_error unableToFetchCurrentTime
 Exception: Time provider problem.
 
typedef std::logic_error formatProblemWithStructTM
 Exception: Bad field(s) in struct tm
 

Public Member Functions

 epicsTime ()
 The default constructor sets the time to the EPICS epoch.
 
size_t strftime (char *pBuff, size_t bufLength, const char *pFormat) const
 Convert to string in user-specified format. More...
 
void show (unsigned interestLevel) const
 Dump current state to standard out.
 
epicsTimeStamp conversions

Convert to and from EPICS epicsTimeStamp format

 operator const epicsTimeStamp & () const
 Convert to epicsTimeStamp.
 
 epicsTime (const epicsTimeStamp &replace)
 Construct from epicsTimeStamp.
 
epicsTimeoperator= (const epicsTimeStamp &replace)
 Assign from epicsTimeStamp.
 
ANSI C time_t conversions

Convert to and from ANSI C time_t wrapper .

 operator time_t_wrapper () const
 Convert to ANSI C time_t.
 
 epicsTime (const time_t_wrapper &replace)
 Construct from ANSI C time_t.
 
epicsTimeoperator= (const time_t_wrapper &replace)
 Assign from ANSI C time_t.
 
ANSI C struct tm local-time conversions

Convert to and from ANSI Cs struct tm (with nano seconds), adjusted for the local time zone.

 operator local_tm_nano_sec () const
 Convert to struct tm in local time zone.
 
 epicsTime (const local_tm_nano_sec &replace)
 Construct from struct tm in local time zone.
 
epicsTimeoperator= (const local_tm_nano_sec &replace)
 Assign from struct tm in local time zone.
 
ANSI C struct tm UTC conversions

Convert to and from ANSI Cs struct tm (with nano seconds), adjusted for Greenwich Mean Time (UTC).

 operator gm_tm_nano_sec () const
 Convert to struct tm in UTC/GMT.
 
 epicsTime (const gm_tm_nano_sec &replace)
 Construct from struct tm in UTC/GMT.
 
epicsTimeoperator= (const gm_tm_nano_sec &replace)
 Assign from struct tm in UTC.
 
POSIX RT struct timespec conversions

Convert to and from the POSIX RealTime struct timespec format.

 operator struct timespec () const
 Convert to struct timespec
 
 epicsTime (const struct timespec &replace)
 Construct from struct timespec
 
epicsTimeoperator= (const struct timespec &replace)
 Assign from struct timespec
 
BSD's struct timeval conversions

Convert to and from the BSD struct timeval format.

 operator struct timeval () const
 Convert to struct timeval
 
 epicsTime (const struct timeval &replace)
 Construct from struct timeval
 
epicsTimeoperator= (const struct timeval &replace)
 Assign from struct timeval
 
Arithmetic operators

Standard operators involving epicsTime objects and time differences which are always expressed as a double in seconds.

double operator- (const epicsTime &other) const
 lhs minus rhs, in seconds
 
epicsTime operator+ (double delta) const
 lhs plus rhs seconds
 
epicsTime operator- (double delta) const
 lhs minus rhs seconds
 
epicsTime operator+= (double delta)
 add rhs seconds to lhs
 
epicsTime operator-= (double delta)
 subtract rhs seconds from lhs
 
Comparison operators

Standard comparisons between epicsTime objects.

bool operator== (const epicsTime &other) const
 lhs equals rhs
 
bool operator!= (const epicsTime &other) const
 lhs not equal to rhs
 
bool operator<= (const epicsTime &other) const
 rhs no later than lhs
 
bool operator< (const epicsTime &other) const
 lhs was before rhs
 
bool operator>= (const epicsTime &other) const
 rhs not before lhs
 
bool operator> (const epicsTime &other) const
 lhs was after rhs
 

Static Public Member Functions

static epicsTime getEvent (const epicsTimeEvent &evt)
 Get time of event system event. More...
 
static epicsTime getCurrent ()
 Get current clock time. More...
 
static epicsTime getMonotonic ()
 Get current monotonic time. More...
 

Detailed Description

Holds an EPICS time stamp, and provides conversion functions for both input and output from/to other types.

Note
Time conversions: The epicsTime implementation will properly convert between the various formats from the beginning of the EPICS epoch until at least 2038. Unless the underlying architecture support has defective POSIX, BSD/SRV5, or standard C time support the EPICS implementation should be valid until 2106.

Definition at line 320 of file epicsTime.h.

Member Function Documentation

static epicsTime epicsTime::getEvent ( const epicsTimeEvent evt)
inlinestatic

Returns an epicsTime indicating when the associated event system event last occurred.

static epicsTime epicsTime::getCurrent ( )
static

Returns an epicsTime containing the current time. For example:

static epicsTime epicsTime::getMonotonic ( )
inlinestatic

Returns an epicsTime containing the current monotonic time, an OS clock which never going backwards or jumping forwards. This time is has an undefined epoch, and is only useful for measuring time differences.

Definition at line 360 of file epicsTime.h.

size_t epicsTime::strftime ( char *  pBuff,
size_t  bufLength,
const char *  pFormat 
) const
inline

This method extends the standard C library routine strftime(). See your OS documentation for details about the standard routine. The epicsTime method adds support for printing the fractional portion of the time. It searches the format string for the sequence %0nf where n is the desired precision, and uses this format to convert the fractional seconds with the requested precision. For example:

char buf[30];
time.strftime(buf, 30, "%Y-%m-%d %H:%M:%S.%06f");
printf("%s\n", buf);

This will print the current time in the format:

2001-01-26 20:50:29.813505

Definition at line 568 of file epicsTime.h.


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