Class TimeStamp

Class Documentation

class TimeStamp

Methods for manipulating timeStamp.

A timeStamp structure has the following fields:

structure
    long secondsPastEpoch
    int nanoseconds
    int userTag
This is a class that holds values corresponding to the fields in a timeStamp structure. It is meant to be used together with pvTimeStamp which allows values to be copied between an timeStamp structure and this class. This class should not be extended.

Public Functions

inline TimeStamp()

Default constructor

TimeStamp(int64 secondsPastEpoch, int32 nanoseconds = 0, int64 userTag = 0)

Constructor

Parameters
  • secondsPastEpoch – seconds since 1970 UTC

  • nanoseconds – nanoseconds since secondsPastEpoch

  • userTag – application specific

void normalize()

adjust secondsPastEpoch and nanoseconds so that 0 <= nanoseconds < nanoSecPerSec

void fromTime_t(const time_t &time)

Set timeStamp from standard C time

Parameters

time – time as returned by std::time

void toTime_t(time_t &time) const

Set time from timeStamp

Parameters

time – time as defined by std::time

inline int64 getSecondsPastEpoch() const

Get secondsPastEpoch.

Returns

The secondsPastEpoch.

inline int64 getEpicsSecondsPastEpoch() const

Get secondsPastEpoch for EPICS V3. This is seconds since 1990 UTC.

Returns

The epics V3 secondsPastEpoch.

inline int32 getNanoseconds() const

Get nanoseconds.

Returns

nanoseconds within timeStamp.

inline int64 getUserTag() const

Get userTag.

Returns

userTag.

inline void setUserTag(int64 userTag)

Set userTag.

Parameters

userTag – application specific.

inline void put(int64 secondsPastEpoch, int32 nanoseconds = 0)

Set time fields in timeStamp. Result will be normalized.

Parameters
  • secondsPastEpoch – seconds part of timeStamp.

  • nanoseconds – nanoseconds part of timeStamp.

void put(int64 milliseconds)

Set time fields in timeStamp.

Parameters

milliseconds – The number of milliseconds since the epoch.

void getCurrent()

Set the timeStamp to the current time.

double toSeconds() const

Convert the timeStamp to a double value that is seconds past epoch.

Returns

seconds past 1970 UTC

bool operator==(TimeStamp const&) const

Standard C++ operator.

bool operator!=(TimeStamp const&) const

Standard C++ operator.

bool operator<=(TimeStamp const&) const

Standard C++ operator.

bool operator<(TimeStamp const&) const

Standard C++ operator.

bool operator>=(TimeStamp const&) const

Standard C++ operator.

bool operator>(TimeStamp const&) const

Standard C++ operator.

TimeStamp &operator+=(int64 seconds)

Standard C++ operator.

TimeStamp &operator-=(int64 seconds)

Standard C++ operator.

TimeStamp &operator+=(double seconds)

Standard C++ operator.

TimeStamp &operator-=(double seconds)

Standard C++ operator.

int64 getMilliseconds()

Get number of milliseconds past epoch.

Returns

milliseconds past epoch.

Public Static Functions

static double diff(TimeStamp const &a, TimeStamp const &b)

Return a-b as a double value with units of seconds.

Parameters
  • a – first timeStamp

  • b – second timeStamp

Returns

time difference in seconds.