Skip to content

Epochstamp

class Epochstamp

This class expresses a point in time and holds its value in the form of two unsigned 64bit. The first expresses the total number of seconds elapsed since Unix epoch, i.e. 1970-01-01 00:00:00.00. The second expresses the number fractional of a seconds, in atto seconds, since the last time unit (in seconds).

The default constructor initializes a Epochstamp object with the current system time. To initialize using an arbitrary point in time the static from functions must be used (e.g. DateTimeString class)

Operators

Name Description
operator= Portability operators to convert other system time structures to Epochstamp tm : time_t value tv : timeval struct ts : timespec struct
operator== Relational operations between timestamps other : Epochstamp object Return : bool
operator+ Move a timestamp forward/backward with given time distance, expressed in terms of time duration duration : TimeDuration object Return : Epochstamp object
operator- Time duration is the difference between two timestamps other : Epochstamp object Return : TimeDuration object
operator++ Auto increment/decrement operators

Functions

Name Description
Epochstamp The default constructor creates a timestamps using the current time
Epochstamp Constructor from seconds and fraction seconds : seconds past since the Unix epoch fraction : attoSeconds past since the second under consideration
Epochstamp Constructor from implicit conversion from other system time structures, time_t : timeval : timespec :
getSeconds Get the second (resp.
getTime Portability functions to convert Epochstamp to other system time structures Return : time_t value Return : timeval struct Return : timespec struct
now Retrieve current time for the system.
elapsed Calculate elapsed time duration between two timestamps other : Epochstamp object (by default, current time point) Return : TimeDuration object
toIso8601 Generates a sting (respecting ISO-8601) for object time for INTERNAL usage ("%Y%m%dT%H%M%S%f" => "20121225T132536.789333[123456789123]") precision : - Indicates the precision of the fractional seconds (e.g. MILLISEC, MICROSEC, NANOSEC, PICOSEC, FEMTOSEC, ATTOSEC) [Default: MICROSEC] extended : - "true" returns ISO8601 extended string; "false" returns ISO8601 compact string [Default: false] Return : ISO 8601 formatted string (extended or compact)
toIso8601Ext Generates a sting (respecting ISO-8601) for object time for EXTERNAL usage ("%Y%m%dT%H%M%S%f%z" => "20121225T132536.789333[123456789123]Z") precision : - Indicates the precision of the fractional seconds (e.g. MILLISEC, MICROSEC, NANOSEC, PICOSEC, FEMTOSEC, ATTOSEC) [Default: MICROSEC] extended : - "true" returns ISO8601 extended string; "false" returns ISO8601 compact string [Default: false] Return : ISO 8601 formatted string with "Z" in the string end ("Z" means the date time zone is using Coordinated Universal Time - UTC)
toTimestamp Generates a timestamp as double with seconds.fractional format (fractional precision == MICROSEC) Function necessary to use in graphs plotting in Python code (MICROSEC precision is enough) Return : A double value with the decimal point indicating fractions of seconds
toFormattedString Formats to specified format time stored in the object format : The format of the time point (visit strftime for more info: http://www.cplusplus.com/reference/ctime/strftime/) [Default: "%Y-%b-%d %H:%M:%S"] localTimeZone : - String that represents an ISO8601 time zone [Default: "Z" == UTC] Return : formated string in the specified Time Zone
toFormattedStringLocale Formats to specified format time stored in the object localeName : - String that represents the locale to be used [Default: "" == System locale] format : The format of the time point (visit strftime for more info: http://www.cplusplus.com/reference/ctime/strftime/) [Default: "%Y-%b-%d %H:%M:%S"] localTimeZone : - String that represents an ISO8601 time zone [Default: "Z" == UTC] Return : formated string in the specified Time Zone
fromHashAttributes Creates an EpochStamp from two Hash attributes This function throws in case the attributes do no provide the correct information attributes : Hash attributes Return : EpochStamp object
toHashAttributes Formats as Hash attributes attributes : container to which the time point information is added
toFormattedStringInternal Formats to specified format time stored in the object localeName : - String that represents the locale to be used [Default: "" == System locale] format : The format of the time point (visit strftime for more info: http://www.cplusplus.com/reference/ctime/strftime/) [Default: "%Y-%b-%d %H:%M:%S"] localTimeZone : - String that represents an ISO8601 time zone [Default: "Z" == UTC] Return : formated string in the specified Time Zone
toIso8601Internal Generates a sting (respecting ISO-8601) for object time for INTERNAL usage ("%Y%m%dT%H%M%S%f" => "20121225T132536.789333[123456789123]") precision : - Indicates the precision of the fractional seconds (e.g. MILLISEC, MICROSEC, NANOSEC, PICOSEC, FEMTOSEC, ATTOSEC) [Default: MICROSEC] extended : - "true" returns ISO8601 extended string; "false" returns ISO8601 compact string [Default: false] localTimeZone : - String that represents an ISO8601 time zone [Default: "Z" == UTC] Return : ISO 8601 formatted string (extended or compact)
concatDateTimeWithFractional Concatenates date and time information with instance fractional seconds within a specified precision dateTime : - Date and time information precision : - Indicates the precision of the fractional seconds (e.g. MILLISEC, MICROSEC, NANOSEC, PICOSEC, FEMTOSEC, ATTOSEC) [Default: MICROSEC] Return : Concatenation result

Operator Details

operator+

Epochstamp operator+(const TimeDuration& duration) const

Move a timestamp forward/backward with given time distance, expressed in terms of time duration

duration : TimeDuration object

Return : Epochstamp object

operator++

Epochstamp operator++(int)

Auto increment/decrement operators

operator-

TimeDuration operator-(const Epochstamp& other) const

Time duration is the difference between two timestamps

other : Epochstamp object

Return : TimeDuration object

operator=

Epochstamp& operator=(const time_t& tm)

Portability operators to convert other system time structures to Epochstamp

tm : time_t value

tv : timeval struct

ts : timespec struct

operator==

bool operator==(const Epochstamp& lhs, const Epochstamp& rhs)

Relational operations between timestamps

other : Epochstamp object

Return : bool

Function Details

Epochstamp

Epochstamp()

The default constructor creates a timestamps using the current time

Epochstamp(const unsigned long long& seconds, const unsigned long long& fractions)

Constructor from seconds and fraction

seconds : seconds past since the Unix epoch

fraction : attoSeconds past since the second under consideration

explicit Epochstamp(const time_t& tm)

Constructor from implicit conversion from other system time structures,

time_t :

timeval :

timespec :

concatDateTimeWithFractional

template <typename To, typename PT1> const To concatDateTimeWithFractional(const PT1 dateTime, const TIME_UNITS precision) const

Concatenates date and time information with instance fractional seconds within a specified precision

dateTime : - Date and time information

precision : - Indicates the precision of the fractional seconds (e.g. MILLISEC, MICROSEC, NANOSEC, PICOSEC, FEMTOSEC, ATTOSEC) [Default: MICROSEC]

Return : Concatenation result

elapsed

TimeDuration elapsed(const Epochstamp& other = Epochstamp()) const

Calculate elapsed time duration between two timestamps

other : Epochstamp object (by default, current time point)

Return : TimeDuration object

fromHashAttributes

static Epochstamp fromHashAttributes(const Hash::Attributes& attributes)

Creates an EpochStamp from two Hash attributes This function throws in case the attributes do no provide the correct information

attributes : Hash attributes

Return : EpochStamp object

getSeconds

inline const unsigned long long& getSeconds() const

Get the second (resp. fractional of a second) part,

Return : unsigned int 64bits

getTime

time_t getTime() const

Portability functions to convert Epochstamp to other system time structures

Return : time_t value

Return : timeval struct

Return : timespec struct

now

void now()

Retrieve current time for the system. Highest resolution is Nano-seconds

toFormattedString

std::string toFormattedString(const std::string& format = "%Y-%b-%d %H:%M:%S", const std::string& localTimeZone = "Z") const

Formats to specified format time stored in the object

format : The format of the time point (visit strftime for more info: http://www.cplusplus.com/reference/ctime/strftime/) [Default: "%Y-%b-%d %H:%M:%S"]

localTimeZone : - String that represents an ISO8601 time zone [Default: "Z" == UTC]

Return : formated string in the specified Time Zone

toFormattedStringInternal

std::string toFormattedStringInternal(const std::string& localeName, const std::string& format, const std::string& localTimeZone) const

Formats to specified format time stored in the object

localeName : - String that represents the locale to be used [Default: "" == System locale]

format : The format of the time point (visit strftime for more info: http://www.cplusplus.com/reference/ctime/strftime/) [Default: "%Y-%b-%d %H:%M:%S"]

localTimeZone : - String that represents an ISO8601 time zone [Default: "Z" == UTC]

Return : formated string in the specified Time Zone

toFormattedStringLocale

std::string toFormattedStringLocale(const std::string& localeName = "", const std::string& format = "%Y-%b-%d %H:%M:%S", const std::string& localTimeZone = "Z") const

Formats to specified format time stored in the object

localeName : - String that represents the locale to be used [Default: "" == System locale]

format : The format of the time point (visit strftime for more info: http://www.cplusplus.com/reference/ctime/strftime/) [Default: "%Y-%b-%d %H:%M:%S"]

localTimeZone : - String that represents an ISO8601 time zone [Default: "Z" == UTC]

Return : formated string in the specified Time Zone

toHashAttributes

void toHashAttributes(Hash::Attributes& attributes) const

Formats as Hash attributes

attributes : container to which the time point information is added

toIso8601

std::string toIso8601(TIME_UNITS precision = MICROSEC, bool extended = false) const

Generates a sting (respecting ISO-8601) for object time for INTERNAL usage ("%Y%m%dT%H%M%S%f" => "20121225T132536.789333[123456789123]")

precision : - Indicates the precision of the fractional seconds (e.g. MILLISEC, MICROSEC, NANOSEC, PICOSEC, FEMTOSEC, ATTOSEC) [Default: MICROSEC]

extended : - "true" returns ISO8601 extended string; "false" returns ISO8601 compact string [Default: false]

Return : ISO 8601 formatted string (extended or compact)

toIso8601Ext

std::string toIso8601Ext(TIME_UNITS precision = MICROSEC, bool extended = false) const

Generates a sting (respecting ISO-8601) for object time for EXTERNAL usage ("%Y%m%dT%H%M%S%f%z" => "20121225T132536.789333[123456789123]Z")

precision : - Indicates the precision of the fractional seconds (e.g. MILLISEC, MICROSEC, NANOSEC, PICOSEC, FEMTOSEC, ATTOSEC) [Default: MICROSEC]

extended : - "true" returns ISO8601 extended string; "false" returns ISO8601 compact string [Default: false]

Return : ISO 8601 formatted string with "Z" in the string end ("Z" means the date time zone is using Coordinated Universal Time - UTC)

toIso8601Internal

std::string toIso8601Internal(TIME_UNITS precision = MICROSEC, bool extended = false, const std::string& localTimeZone = "") const

Generates a sting (respecting ISO-8601) for object time for INTERNAL usage ("%Y%m%dT%H%M%S%f" => "20121225T132536.789333[123456789123]")

precision : - Indicates the precision of the fractional seconds (e.g. MILLISEC, MICROSEC, NANOSEC, PICOSEC, FEMTOSEC, ATTOSEC) [Default: MICROSEC]

extended : - "true" returns ISO8601 extended string; "false" returns ISO8601 compact string [Default: false]

localTimeZone : - String that represents an ISO8601 time zone [Default: "Z" == UTC]

Return : ISO 8601 formatted string (extended or compact)

toTimestamp

const double toTimestamp() const

Generates a timestamp as double with seconds.fractional format (fractional precision == MICROSEC) Function necessary to use in graphs plotting in Python code (MICROSEC precision is enough)

Return : A double value with the decimal point indicating fractions of seconds