StreamBase C++ API  7.6.2dev
sb::Timestamp Class Reference

Class for representing moments in time and intervals at millisecond granularity. More...

#include <Timestamp.hpp>

Public Member Functions

 Timestamp ()
 Create a default Timestamp. More...
 
Timestamp operator- () const
 Negate an interval to return an interval. More...
 
Timestamp operator- (const Timestamp &rhs) const
 Subtract two Timestamps to return an interval. More...
 
Timestamp operator+ (const Timestamp &rhs) const
 Add a Timestamp and an interval to get a Timestamp. More...
 
Timestampoperator+= (const Timestamp &rhs)
 Increment the Timestamp by the interval. More...
 
Timestampoperator-= (const Timestamp &rhs)
 Decrement the Timestamp by the interval. More...
 
template<typename T >
Timestamp operator* (T rhs) const
 Multiply a Timestamp representing an interval by a constant. More...
 
template<typename T >
Timestampoperator*= (T rhs)
 Multiply a Timestamp representing an interval by a constant. More...
 
template<typename T >
Timestamp operator/ (T rhs) const
 Divide a Timestamp representing an interval by a constant. More...
 
template<typename T >
Timestampoperator/= (T rhs)
 Divide a Timestamp representing an interval by a constant. More...
 
double operator/ (Timestamp rhs) const
 Divide two Timestamps representing an interval to find their quotient. More...
 
Timestamp operator% (const Timestamp &rhs) const
 Modulo a Timestamp by an interval. More...
 
Timestamp operator%= (const Timestamp &rhs)
 Modulo a Timestamp by an interval. More...
 
bool operator< (const Timestamp &rhs) const
 Return true if this Timestamp is before rhs. More...
 
bool operator<= (const Timestamp &rhs) const
 Return true if this Timestamp is before or at the same time as rhs. More...
 
bool operator== (const Timestamp &rhs) const
 Return true if this Timestamp is at the same time as rhs. More...
 
bool operator!= (const Timestamp &rhs) const
 Return true if this Timestamp is not at the same time as rhs. More...
 
bool operator>= (const Timestamp &rhs) const
 Return true if this Timestamp is after or at the same time as rhs. More...
 
bool operator> (const Timestamp &rhs) const
 Return true if this Timestamp is after rhs. More...
 
bool isInterval () const
 Return true if this Timestamp is an interval. More...
 
long long toMsecs () const
 Return the time as milliseconds. More...
 
long long toSecs () const
 Return the time as seconds. More...
 
int compare (const Timestamp &other) const
 compare 2 timestamps return less than zero this < other return greater than zero this > other return 0 if they are the same More...
 
double getSecond () const
 Return seconds after the minute. More...
 
double getMillisecond () const
 Return milliseconds after the second. More...
 
int getMinute () const
 Return minutes after hour. More...
 
int getHour () const
 Return hours since midnight. More...
 
int getDayOfWeek () const
 Return day since Sunday. More...
 
int getDayOfMonth () const
 Return day of month. More...
 
int getMonth () const
 Return month since January. More...
 
int getYear () const
 Return year. More...
 
void setSecond (double seconds)
 Set seconds after the minute. More...
 
void setMinute (int minutes)
 Set minutes after the hour. More...
 
void setHour (int hours)
 Set hours since midnight. More...
 
void setDayOfMonth (int day_of_month)
 Set day of month. More...
 
void setMonth (int month)
 Set month since January. More...
 
void setYear (int year)
 Set year. More...
 
std::string as_string (bool displayTimezone=true) const
 Return a human readable string rep of this Timestamp. More...
 

Static Public Member Functions

static Timestamp now ()
 Return a Timestamp representing the current moment in time. More...
 
static Timestamp milliseconds (long long milliseconds)
 Create a time from a count of milliseconds. More...
 
template<typename T >
static Timestamp seconds (T seconds)
 Create a time from a count of seconds. More...
 
static Timestamp seconds (double seconds)
 Create a time from a count of seconds. More...
 
template<typename T >
static Timestamp minutes (T minutes)
 Construct an interval from minutes. More...
 
static Timestamp minutes (double minutes)
 Construct an interval from minutes. More...
 
template<typename T >
static Timestamp hours (T hours)
 Construct an interval from hours. More...
 
static Timestamp hours (double hours)
 Construct an interval from hours. More...
 
template<typename T >
static Timestamp days (T days)
 Construct an interval from days. More...
 
static Timestamp days (double days)
 Construct an interval from days. More...
 
template<typename T >
static Timestamp weeks (T weeks)
 Construct an interval from weeks. More...
 
static Timestamp weeks (double weeks)
 Construct an interval from weeks. More...
 

Static Public Attributes

static const int MIN_YEAR = 1400
 
static const int MAX_YEAR = 9999
 
static const int MIN_MONTH = 1
 
static const int MAX_MONTH = 12
 
static const int MIN_DAY = 1
 
static const int MAX_DAY = 31
 
static const int MIN_HOUR = 0
 
static const int MAX_HOUR = 23
 
static const int MIN_MINUTE = 0
 
static const int MAX_MINUTE = 59
 
static const int MIN_SECOND = 0
 
static const int MAX_SECOND = 59
 

Detailed Description

Class for representing moments in time and intervals at millisecond granularity.

Constructor & Destructor Documentation

sb::Timestamp::Timestamp ( )
inline

Create a default Timestamp.

Will initialized to 00:00:00 1 Jan 1970.

Member Function Documentation

std::string sb::Timestamp::as_string ( bool  displayTimezone = true) const

Return a human readable string rep of this Timestamp.

int sb::Timestamp::compare ( const Timestamp other) const
inline

compare 2 timestamps return less than zero this < other return greater than zero this > other return 0 if they are the same

template<typename T >
static Timestamp sb::Timestamp::days ( days)
inlinestatic

Construct an interval from days.

static Timestamp sb::Timestamp::days ( double  days)
inlinestatic

Construct an interval from days.

int sb::Timestamp::getDayOfMonth ( ) const

Return day of month.

int sb::Timestamp::getDayOfWeek ( ) const

Return day since Sunday.

int sb::Timestamp::getHour ( ) const

Return hours since midnight.

double sb::Timestamp::getMillisecond ( ) const

Return milliseconds after the second.

int sb::Timestamp::getMinute ( ) const

Return minutes after hour.

int sb::Timestamp::getMonth ( ) const

Return month since January.

double sb::Timestamp::getSecond ( ) const

Return seconds after the minute.

int sb::Timestamp::getYear ( ) const

Return year.

template<typename T >
static Timestamp sb::Timestamp::hours ( hours)
inlinestatic

Construct an interval from hours.

static Timestamp sb::Timestamp::hours ( double  hours)
inlinestatic

Construct an interval from hours.

bool sb::Timestamp::isInterval ( ) const
inline

Return true if this Timestamp is an interval.

static Timestamp sb::Timestamp::milliseconds ( long long  milliseconds)
inlinestatic

Create a time from a count of milliseconds.

template<typename T >
static Timestamp sb::Timestamp::minutes ( minutes)
inlinestatic

Construct an interval from minutes.

static Timestamp sb::Timestamp::minutes ( double  minutes)
inlinestatic

Construct an interval from minutes.

static Timestamp sb::Timestamp::now ( )
static

Return a Timestamp representing the current moment in time.

bool sb::Timestamp::operator!= ( const Timestamp rhs) const
inline

Return true if this Timestamp is not at the same time as rhs.

Timestamp sb::Timestamp::operator% ( const Timestamp rhs) const
inline

Modulo a Timestamp by an interval.

Timestamp sb::Timestamp::operator%= ( const Timestamp rhs)
inline

Modulo a Timestamp by an interval.

template<typename T >
Timestamp sb::Timestamp::operator* ( rhs) const
inline

Multiply a Timestamp representing an interval by a constant.

template<typename T >
Timestamp& sb::Timestamp::operator*= ( rhs)
inline

Multiply a Timestamp representing an interval by a constant.

Timestamp sb::Timestamp::operator+ ( const Timestamp rhs) const

Add a Timestamp and an interval to get a Timestamp.

Add two intervals to return an interval.

Timestamp& sb::Timestamp::operator+= ( const Timestamp rhs)

Increment the Timestamp by the interval.

Timestamp sb::Timestamp::operator- ( ) const

Negate an interval to return an interval.

Negate a timestamp to return a timestamp, even though that doesn't make much sense.

Timestamp sb::Timestamp::operator- ( const Timestamp rhs) const

Subtract two Timestamps to return an interval.

Subtract two intervals to return an interval. Subtract an interval from a Timestamp to return a Timestamp.

Timestamp& sb::Timestamp::operator-= ( const Timestamp rhs)

Decrement the Timestamp by the interval.

template<typename T >
Timestamp sb::Timestamp::operator/ ( rhs) const
inline

Divide a Timestamp representing an interval by a constant.

double sb::Timestamp::operator/ ( Timestamp  rhs) const
inline

Divide two Timestamps representing an interval to find their quotient.

template<typename T >
Timestamp& sb::Timestamp::operator/= ( rhs)
inline

Divide a Timestamp representing an interval by a constant.

bool sb::Timestamp::operator< ( const Timestamp rhs) const
inline

Return true if this Timestamp is before rhs.

bool sb::Timestamp::operator<= ( const Timestamp rhs) const
inline

Return true if this Timestamp is before or at the same time as rhs.

bool sb::Timestamp::operator== ( const Timestamp rhs) const
inline

Return true if this Timestamp is at the same time as rhs.

bool sb::Timestamp::operator> ( const Timestamp rhs) const
inline

Return true if this Timestamp is after rhs.

bool sb::Timestamp::operator>= ( const Timestamp rhs) const
inline

Return true if this Timestamp is after or at the same time as rhs.

template<typename T >
static Timestamp sb::Timestamp::seconds ( seconds)
inlinestatic

Create a time from a count of seconds.

static Timestamp sb::Timestamp::seconds ( double  seconds)
inlinestatic

Create a time from a count of seconds.

void sb::Timestamp::setDayOfMonth ( int  day_of_month)

Set day of month.

void sb::Timestamp::setHour ( int  hours)

Set hours since midnight.

void sb::Timestamp::setMinute ( int  minutes)

Set minutes after the hour.

void sb::Timestamp::setMonth ( int  month)

Set month since January.

void sb::Timestamp::setSecond ( double  seconds)

Set seconds after the minute.

void sb::Timestamp::setYear ( int  year)

Set year.

long long sb::Timestamp::toMsecs ( ) const
inline

Return the time as milliseconds.

long long sb::Timestamp::toSecs ( ) const
inline

Return the time as seconds.

template<typename T >
static Timestamp sb::Timestamp::weeks ( weeks)
inlinestatic

Construct an interval from weeks.

static Timestamp sb::Timestamp::weeks ( double  weeks)
inlinestatic

Construct an interval from weeks.


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