BDS Public
Beamlib 3.3.4
This is the Beam C++ class library.
Loading...
Searching...
No Matches

A date and time storage class with microsecond resolution. More...

#include <BTimeStamp.h>

Public Member Functions

 BTimeStamp ()
 
 BTimeStamp (int year, int month=1, int day=1, int hour=0, int minute=0, int second=0, int microsecond=0)
 
 BTimeStamp (const BString str)
 
 ~BTimeStamp ()
 
void clear ()
 Clear the date/time.
 
void setFirst ()
 Set the first date available.
 
void setLast ()
 Set the last date available.
 
void set (time_t time, int microSeconds)
 Set time using Unix time (seconds from 1970-01-01)
 
void set (int year=0, int month=1, int day=1, int hour=0, int minute=0, int second=0, int microsecond=0)
 
void set (const BTimeStampMs &timeStamp)
 Set the timeStamp to given MS time stamp.
 
void setYDay (int year=0, int yday=0, int hour=0, int minute=0, int second=0, int microsecond=0)
 
void setTime (int hour=0, int minute=0, int second=0, int microsecond=0)
 
void setNow ()
 Set the timeStamp to now.
 
int year () const
 
int yday () const
 
int month () const
 
int day () const
 
int hour () const
 
int minute () const
 
int second () const
 
int microSecond () const
 
void getDate (int &year, int &mon, int &day) const
 
BString getString (BString separator="T") const
 Get the time as an ISO date/time string.
 
BError setString (const BString dateTime)
 Set the time from an ISO date/time.
 
BString getStringNoMs (BString separator="T") const
 Get the time as an ISO date/time string without microseconds.
 
BString getStringFormatted (BString format) const
 Gets the time in a string form as per the format. Format syntax as per strftime()
 
void addMilliSeconds (int milliSeconds)
 Add the given number of milli seconds. This should be less that a year.
 
void addMicroSeconds (int64_t microSeconds)
 Add the given number of micro seconds. This should be less that a year.
 
void addSeconds (int seconds)
 Add the given number of seconds. This should be less that a year.
 
uint32_t getYearSeconds () const
 Get number of seconds within the year.
 
uint64_t getYearMicroSeconds () const
 Get number of micro seconds within the year.
 
int isSet () const
 
int compare (const BTimeStamp &timeStamp) const
 Compare two dates.
 
 operator BString () const
 
BTimeStampoperator= (const BTimeStampMs &timeStamp)
 
int operator== (const BTimeStamp &timeStamp) const
 
int operator!= (const BTimeStamp &timeStamp) const
 
int operator> (const BTimeStamp &timeStamp) const
 
int operator>= (const BTimeStamp &timeStamp) const
 
int operator< (const BTimeStamp &timeStamp) const
 
int operator<= (const BTimeStamp &timeStamp) const
 

Static Public Member Functions

static int isLeap (int year)
 
static BInt64 difference (BTimeStamp t2, BTimeStamp t1)
 

Public Attributes

BUInt16 oyear
 Year (0 .. 65535)
 
BUInt16 oyday
 Day in year (0 .. 365)
 
BUInt8 ohour
 Hour (0 .. 23)
 
BUInt8 ominute
 Minute (0 .. 59)
 
BUInt8 osecond
 Second (0 .. 59)
 
BUInt8 ospare
 Padding.
 
BUInt32 omicroSecond
 MicroSecond (0 .. 999999)
 

Detailed Description

A date and time storage class with microsecond resolution.

Constructor & Destructor Documentation

◆ BTimeStamp() [1/3]

BTimeStamp::BTimeStamp ( )

◆ BTimeStamp() [2/3]

BTimeStamp::BTimeStamp ( int  year,
int  month = 1,
int  day = 1,
int  hour = 0,
int  minute = 0,
int  second = 0,
int  microsecond = 0 
)

◆ BTimeStamp() [3/3]

BTimeStamp::BTimeStamp ( const BString  str)

◆ ~BTimeStamp()

BTimeStamp::~BTimeStamp ( )

Member Function Documentation

◆ clear()

void BTimeStamp::clear ( )

Clear the date/time.

◆ setFirst()

void BTimeStamp::setFirst ( )

Set the first date available.

◆ setLast()

void BTimeStamp::setLast ( )

Set the last date available.

◆ set() [1/3]

void BTimeStamp::set ( time_t  time,
int  microSeconds 
)

Set time using Unix time (seconds from 1970-01-01)

◆ set() [2/3]

void BTimeStamp::set ( int  year = 0,
int  month = 1,
int  day = 1,
int  hour = 0,
int  minute = 0,
int  second = 0,
int  microsecond = 0 
)

◆ set() [3/3]

void BTimeStamp::set ( const BTimeStampMs timeStamp)

Set the timeStamp to given MS time stamp.

◆ setYDay()

void BTimeStamp::setYDay ( int  year = 0,
int  yday = 0,
int  hour = 0,
int  minute = 0,
int  second = 0,
int  microsecond = 0 
)

◆ setTime()

void BTimeStamp::setTime ( int  hour = 0,
int  minute = 0,
int  second = 0,
int  microsecond = 0 
)

◆ setNow()

void BTimeStamp::setNow ( )

Set the timeStamp to now.

◆ year()

int BTimeStamp::year ( ) const

◆ yday()

int BTimeStamp::yday ( ) const

◆ month()

int BTimeStamp::month ( ) const

◆ day()

int BTimeStamp::day ( ) const

◆ hour()

int BTimeStamp::hour ( ) const

◆ minute()

int BTimeStamp::minute ( ) const

◆ second()

int BTimeStamp::second ( ) const

◆ microSecond()

int BTimeStamp::microSecond ( ) const

◆ getDate()

void BTimeStamp::getDate ( int &  year,
int &  mon,
int &  day 
) const

◆ getString()

BString BTimeStamp::getString ( BString  separator = "T") const

Get the time as an ISO date/time string.

◆ setString()

BError BTimeStamp::setString ( const BString  dateTime)

Set the time from an ISO date/time.

This accepts a string and parses for a supported datetime format string. The function will return an error if it cannot parse a datatime string or if one of the parsed fields is out of range. The conversion supports a fractional second resolution of 1 microsecond rounding the fractional value given to this. Supported formats include: ISO: YYYY-MM-DD[ T]HH:MM:SS.FS, UK: YYYY/MM/DD[ T]HH:MM:SS.FS, UK: YY/MM/DD[ T]HH:MM:SS.FS, HH:MM:SS.FS and YYYYDDD[ T]HH:MM:SS.FS.

◆ getStringNoMs()

BString BTimeStamp::getStringNoMs ( BString  separator = "T") const

Get the time as an ISO date/time string without microseconds.

◆ getStringFormatted()

BString BTimeStamp::getStringFormatted ( BString  format) const

Gets the time in a string form as per the format. Format syntax as per strftime()

◆ addMilliSeconds()

void BTimeStamp::addMilliSeconds ( int  milliSeconds)

Add the given number of milli seconds. This should be less that a year.

◆ addMicroSeconds()

void BTimeStamp::addMicroSeconds ( int64_t  microSeconds)

Add the given number of micro seconds. This should be less that a year.

◆ addSeconds()

void BTimeStamp::addSeconds ( int  seconds)

Add the given number of seconds. This should be less that a year.

◆ getYearSeconds()

uint32_t BTimeStamp::getYearSeconds ( ) const

Get number of seconds within the year.

◆ getYearMicroSeconds()

uint64_t BTimeStamp::getYearMicroSeconds ( ) const

Get number of micro seconds within the year.

◆ isSet()

int BTimeStamp::isSet ( ) const
inline

◆ compare()

int BTimeStamp::compare ( const BTimeStamp timeStamp) const

Compare two dates.

◆ operator BString()

BTimeStamp::operator BString ( ) const
inline

◆ operator=()

BTimeStamp & BTimeStamp::operator= ( const BTimeStampMs timeStamp)
inline

◆ operator==()

int BTimeStamp::operator== ( const BTimeStamp timeStamp) const
inline

◆ operator!=()

int BTimeStamp::operator!= ( const BTimeStamp timeStamp) const
inline

◆ operator>()

int BTimeStamp::operator> ( const BTimeStamp timeStamp) const
inline

◆ operator>=()

int BTimeStamp::operator>= ( const BTimeStamp timeStamp) const
inline

◆ operator<()

int BTimeStamp::operator< ( const BTimeStamp timeStamp) const
inline

◆ operator<=()

int BTimeStamp::operator<= ( const BTimeStamp timeStamp) const
inline

◆ isLeap()

int BTimeStamp::isLeap ( int  year)
static

◆ difference()

BInt64 BTimeStamp::difference ( BTimeStamp  t2,
BTimeStamp  t1 
)
static

Member Data Documentation

◆ oyear

BUInt16 BTimeStamp::oyear

Year (0 .. 65535)

◆ oyday

BUInt16 BTimeStamp::oyday

Day in year (0 .. 365)

◆ ohour

BUInt8 BTimeStamp::ohour

Hour (0 .. 23)

◆ ominute

BUInt8 BTimeStamp::ominute

Minute (0 .. 59)

◆ osecond

BUInt8 BTimeStamp::osecond

Second (0 .. 59)

◆ ospare

BUInt8 BTimeStamp::ospare

Padding.

◆ omicroSecond

BUInt32 BTimeStamp::omicroSecond

MicroSecond (0 .. 999999)


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