comet::dateonly_t Struct Reference
[Miscelaneous utility classes.]

Wrapper for a date only class. More...

#include <date.h>

List of all members.

Public Member Functions

 dateonly_t ()
 constructor
 dateonly_t (const datetime_t &dt)
 Construct from a datetime_t.
 dateonly_t (const impl::auto_attach_t< long > &dateval)
 Attach from a long.
long get () const
 Get the raw 'long' value.
dateonly_toperator= (const impl::auto_attach_t< long > &dateval)
 dateonly_t (dt_invalid_t)
 Initialise as invalid.
 dateonly_t (dt_null_t)
 Initialise as null.
 dateonly_t (dt_zero_t)
 Initialise as zero.
 dateonly_t (int year, int month, int day)
 Construct from year/month/day.
void split (int *year, int *month, int *day) const
 Return year/month/day values.
bool set_date (int year, int month, int day)
 operator datetime_t () const
 Convert to datetime.
dateonly_tadd_months (int inc_months)
dateonly_tadd_years (int inc_years)
 Add specified number of years.
bool invalid () const
 return true if the date is marked 'invalid'.
bool null () const
 Return true if the date is marked 'null'.
bool zero () const
 return true if date is zero
bool good () const
 Return true if the date is usable.
bstr_t format (datetime_t::format_flags flags=datetime_t::ff_default, LCID locale=LOCALE_USER_DEFAULT) const
dateonly_tparse (const bstr_t &val, datetime_t::format_flags flags=datetime_t::ff_default, LCID locale=LOCALE_USER_DEFAULT)
template<typename CHAR> std::basic_string< CHAR > format (const std::basic_string< CHAR > &fmt) const
template<typename CHAR> std::basic_string< CHAR > format (const CHAR *fmt) const
Access date parts.
int year () const
 Year.
int month () const
 Month of year (1-based).
int day () const
 Day of month (1-based).
datetime_t::day_of_week dow () const
 The day of week.
int year_day () const
 Day of the year (0 -based).
int days_in_month () const
 Days in the month.
Comparison operators
bool operator== (const dateonly_t &date) const
bool operator!= (const dateonly_t &date) const
bool operator< (const dateonly_t &date) const
bool operator> (const dateonly_t &date) const
bool operator<= (const dateonly_t &date) const
bool operator>= (const dateonly_t &date) const
bool operator== (dt_invalid_t) const
bool operator!= (dt_invalid_t) const
bool operator== (dt_zero_t) const
bool operator!= (dt_zero_t) const
bool operator== (dt_null_t) const
bool operator!= (dt_null_t) const
Arithmetic operators
dateonly_t operator+ (long dateSpan) const
dateonly_t operator- (long dateSpan) const
dateonly_toperator+= (long dateSpan)
dateonly_toperator-= (long dateSpan)
long operator- (const dateonly_t &date) const
dateonly_toperator++ ()
dateonly_t operator++ (int)
dateonly_toperator-- ()
dateonly_t operator-- (int)

Static Public Member Functions

dateonly_t get_null ()
 Get a 'NULL' datetime.
dateonly_t get_zero ()
 Get a 'zero' datetime.
dateonly_t today ()
 Return today.
dateonly_t today_utc ()
 Return today (UTC).
int days_in_month (int year, int month)

Protected Member Functions

 dateonly_t (long l)

Friends

std::basic_ostream< char > & operator<< (std::basic_ostream< char > &os, const dateonly_t &val)
 Stream operator.
std::basic_ostream< wchar_t > & operator<< (std::basic_ostream< wchar_t > &os, const dateonly_t &val)
 Stream operator.


Detailed Description

Wrapper for a date only class.

This is based on an integer version of DATE, except that it is an absolute offset from 1/1/0.


Member Function Documentation

dateonly_t& comet::dateonly_t::add_months int  inc_months  )  [inline]
 

Add specified number of months. If the day is not valid, force to the last day in the month.

template<typename CHAR>
std::basic_string<CHAR> comet::dateonly_t::format const CHAR *  fmt  )  const [inline]
 

Format as basic_string.

Parameters:
fmt See system documentation for strftime for details.

template<typename CHAR>
std::basic_string<CHAR> comet::dateonly_t::format const std::basic_string< CHAR > &  fmt  )  const [inline]
 

Format as basic_string.

Parameters:
fmt See system documentation for strftime for details.

bstr_t comet::dateonly_t::format datetime_t::format_flags  flags = datetime_t::ff_default,
LCID  locale = LOCALE_USER_DEFAULT
const [inline]
 

Format as bstr.

Parameters:
flags Format (can be or-ed). All format_flags are valid.
locale Locale ID (default to User Default.

dateonly_t& comet::dateonly_t::parse const bstr_t val,
datetime_t::format_flags  flags = datetime_t::ff_default,
LCID  locale = LOCALE_USER_DEFAULT
[inline]
 

Parse bstring to a datetime_t.

Parameters:
val String to parse.
flags valid format_flags are: ff_default, ff_system_locale, ff_hijri, ff_time_only, ff_date_only
locale Locale to use. Default locale is the user default.

bool comet::dateonly_t::set_date int  year,
int  month,
int  day
[inline]
 

Set date part as year/month/day.

Parameters:
year Year (from year 0 - as in 2000).
month Month of year (1-based).
day Day of month (1-based).
Return values:
true Successfully set date.
false Conversion unsuccessful - date not set.


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