OnixS CME Drop Copy Handler for C++  5.3.0.0
Public Member Functions | Static Public Member Functions | List of all members
YearMonth Class Reference

Represents month-year pair. More...

Public Member Functions

 YearMonth ()
 Initializes instance as Jan, 0001.
 
 YearMonth (UInt32 year, Month month)
 Initializes instance with given values according YYYYMM (year/month) format. More...
 
 YearMonth (UInt32 year, Month month, UInt32 day)
 Initializes instance with given values according YYYYMMDD (year/month/day) format. More...
 
 YearMonth (UInt32 year, Month month, WeekCode week)
 Initializes instance with given values according YYYYMMWW (year/month/week) format. More...
 
 YearMonth (const YearMonth &other)
 Initializes as copy of other instance.
 
UInt32 year () const
 Year component. More...
 
Month month () const
 Month component. More...
 
UInt32 day () const
 Day component. More...
 
WeekCode week () const
 Week component. More...
 
bool hasDay () const
 Checks that instance has valid day component. More...
 
bool hasWeek () const
 Checks that instance has valid week component. More...
 
bool operator== (const YearMonth &) const
 Compares with other instance for equality.
 
bool operator!= (const YearMonth &) const
 Compares with other instance for inequality.
 
bool operator< (const YearMonth &other) const
 Checks whether this instance is less than other one. More...
 
bool operator> (const YearMonth &other) const
 Checks whether this instance is greater than other one. More...
 
YearMonthoperator= (const YearMonth &other)
 
std::string toString () const
 Serializes into text (YYYYMM/YYYYMMDD/YYYYMMWW) presentation.
 
void toString (std::string &) const
 Serializes into text (YYYYMM/YYYYMMDD/YYYYMMWW) presentation.
 

Static Public Member Functions

static YearMonth deserialize (const StringRef &)
 De-serializes instance from its string presentation (YYYYMM/YYYYMMDD/YYYYMMWW) as it's used by CME Globex. More...
 

Detailed Description

Represents month-year pair.

Year must fit into [0001, 9999] range. Month must fit into [01, 12] range.

Constructor & Destructor Documentation

YearMonth ( UInt32  year,
Month  month 
)

Initializes instance with given values according YYYYMM (year/month) format.

Input parameters are checked for validness.

Exceptions
exceptionif input parameters do not fit into a valid range.
YearMonth ( UInt32  year,
Month  month,
UInt32  day 
)

Initializes instance with given values according YYYYMMDD (year/month/day) format.

Input parameters are checked for validness.

Exceptions
exceptionif input parameters do not fit into a valid range.
YearMonth ( UInt32  year,
Month  month,
WeekCode  week 
)

Initializes instance with given values according YYYYMMWW (year/month/week) format.

Input parameters are checked for validness.

Exceptions
exceptionif input parameters do not fit into a valid range.

Member Function Documentation

UInt32 day ( ) const
inline

Day component.

Valid range of values is [01, 31].

static YearMonth deserialize ( const StringRef )
static

De-serializes instance from its string presentation (YYYYMM/YYYYMMDD/YYYYMMWW) as it's used by CME Globex.

bool hasDay ( ) const
inline

Checks that instance has valid day component.

Note: it's not valid to have both valid day and week, only one of them allowed.

bool hasWeek ( ) const
inline

Checks that instance has valid week component.

Note: it's not valid to have both valid day and week, only one of them allowed.

Month month ( ) const
inline

Month component.

Valid range of values is [01, 12].

bool operator< ( const YearMonth other) const

Checks whether this instance is less than other one.

Note: when comparing objects with different date components, e.g. days vs weeks (but same year and month) following order is applied: YYYYMM < YYYYMMWW < YYYYMMDD

bool operator> ( const YearMonth other) const

Checks whether this instance is greater than other one.

Note: when comparing objects with different date components, e.g. days vs weeks (but same year and month) following order is applied: YYYYMMDD > YYYYMMWW > YYYYMM

WeekCode week ( ) const
inline

Week component.

Valid range of values is [1, 5].

UInt32 year ( ) const
inline

Year component.

Valid range of values is [0001, 9999].