DABC (Data Acquisition Backbone Core)  2.9.9
Public Member Functions | Protected Attributes
dabc::DateTime Class Reference

Class for holding GMT time with precision of nanoseconds. More...

#include <dabc/timing.h>

Public Member Functions

double AsDouble () const
 Return date and time in seconds since 1.1.1970. More...
 
uint64_t AsJSDate () const
 Return date and time in JS format - number of millisecond since 1.1.1970. More...
 
std::string AsJSString (int ndecimal=3) const
 convert string into sec.frac format, can be interpret directly in JavaScript ISO 8601 standard is used and produces string like '2013-09-16T12:42:30.884Z' Time in GMT time zone More...
 
std::string AsString (int ndecimal=0, bool localtime=false) const
 convert string into human-readable format, cannot be interpret directly in JavaScript More...
 
unsigned AsUTCSeconds () const
 Returns only seconds since 1.1.1970. More...
 
 DateTime ()
 
 DateTime (const DateTime &src)
 
 DateTime (uint64_t jsdate)
 
double DistanceTo (const DateTime &src) const
 Return distance in seconds to provided date. More...
 
DateTimeGetNow ()
 
bool null () const
 
std::string OnlyDateAsString (const char *separ=nullptr, bool localtime=false) const
 Fills only date as string. More...
 
std::string OnlyTimeAsString (const char *separ=nullptr, bool localtime=false) const
 Fills only time as string. More...
 
double operator- (const DateTime &src) const
 
DateTimeoperator= (const DateTime &src)
 
void SetDouble (double v)
 Set value in form of double - seconds since 1.1.1970. More...
 
void SetJSDate (uint64_t jsdate)
 Set value in form of JS date - milliseconds since 1.1.1970. More...
 
bool SetOnlyDate (const char *sbuf)
 Set only date part from the string. More...
 
bool SetOnlyTime (const char *sbuf)
 Set only time part of DateTime. More...
 

Protected Attributes

unsigned tv_nsec
 
unsigned tv_sec
 

Detailed Description

Class for holding GMT time with precision of nanoseconds.

For time measurement function like gettimeofday is used.

Definition at line 190 of file timing.h.

Constructor & Destructor Documentation

◆ DateTime() [1/3]

dabc::DateTime::DateTime ( )
inline

Definition at line 195 of file timing.h.

◆ DateTime() [2/3]

dabc::DateTime::DateTime ( uint64_t  jsdate)
inline

Definition at line 197 of file timing.h.

◆ DateTime() [3/3]

dabc::DateTime::DateTime ( const DateTime src)
inline

Definition at line 199 of file timing.h.

Member Function Documentation

◆ operator=()

DateTime& dabc::DateTime::operator= ( const DateTime src)
inline

Definition at line 201 of file timing.h.

◆ operator-()

double dabc::DateTime::operator- ( const DateTime src) const
inline

Definition at line 208 of file timing.h.

◆ null()

bool dabc::DateTime::null ( ) const
inline

Definition at line 210 of file timing.h.

◆ GetNow()

dabc::DateTime & dabc::DateTime::GetNow ( )

Definition at line 147 of file timing.cxx.

◆ AsDouble()

double dabc::DateTime::AsDouble ( ) const

Return date and time in seconds since 1.1.1970.

Definition at line 206 of file timing.cxx.

◆ AsJSDate()

uint64_t dabc::DateTime::AsJSDate ( ) const

Return date and time in JS format - number of millisecond since 1.1.1970.

Definition at line 158 of file timing.cxx.

◆ AsUTCSeconds()

unsigned dabc::DateTime::AsUTCSeconds ( ) const
inline

Returns only seconds since 1.1.1970.

Definition at line 221 of file timing.h.

◆ SetJSDate()

void dabc::DateTime::SetJSDate ( uint64_t  jsdate)
inline

Set value in form of JS date - milliseconds since 1.1.1970.

Definition at line 224 of file timing.h.

◆ SetDouble()

void dabc::DateTime::SetDouble ( double  v)
inline

Set value in form of double - seconds since 1.1.1970.

Definition at line 231 of file timing.h.

◆ AsString()

std::string dabc::DateTime::AsString ( int  ndecimal = 0,
bool  localtime = false 
) const

convert string into human-readable format, cannot be interpret directly in JavaScript

Definition at line 164 of file timing.cxx.

◆ AsJSString()

std::string dabc::DateTime::AsJSString ( int  ndecimal = 3) const

convert string into sec.frac format, can be interpret directly in JavaScript ISO 8601 standard is used and produces string like '2013-09-16T12:42:30.884Z' Time in GMT time zone

Definition at line 212 of file timing.cxx.

◆ OnlyDateAsString()

std::string dabc::DateTime::OnlyDateAsString ( const char *  separ = nullptr,
bool  localtime = false 
) const

Fills only date as string.

Definition at line 257 of file timing.cxx.

◆ OnlyTimeAsString()

std::string dabc::DateTime::OnlyTimeAsString ( const char *  separ = nullptr,
bool  localtime = false 
) const

Fills only time as string.

Definition at line 273 of file timing.cxx.

◆ SetOnlyDate()

bool dabc::DateTime::SetOnlyDate ( const char *  sbuf)

Set only date part from the string.

Definition at line 289 of file timing.cxx.

◆ SetOnlyTime()

bool dabc::DateTime::SetOnlyTime ( const char *  sbuf)

Set only time part of DateTime.

Definition at line 308 of file timing.cxx.

◆ DistanceTo()

double dabc::DateTime::DistanceTo ( const DateTime src) const

Return distance in seconds to provided date.

Definition at line 332 of file timing.cxx.

Field Documentation

◆ tv_sec

unsigned dabc::DateTime::tv_sec
protected

Definition at line 192 of file timing.h.

◆ tv_nsec

unsigned dabc::DateTime::tv_nsec
protected

Definition at line 193 of file timing.h.


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