Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::date_time::date< T, calendar, duration_type_ > Class Template Reference

Representation of timepoint at the one day level resolution. More...

#include <date.hpp>

Inheritance diagram for boost::date_time::date< T, calendar, duration_type_ >:
Collaboration diagram for boost::date_time::date< T, calendar, duration_type_ >:

Public Types

typedef T date_type
 
typedef calendar calendar_type
 
typedef calendar::date_traits_type traits_type
 
typedef duration_type_ duration_type
 
typedef calendar::year_type year_type
 
typedef calendar::month_type month_type
 
typedef calendar::day_type day_type
 
typedef calendar::ymd_type ymd_type
 
typedef calendar::date_rep_type date_rep_type
 
typedef calendar::date_int_type date_int_type
 
typedef calendar::day_of_week_type day_of_week_type
 

Public Member Functions

 date (year_type y, month_type m, day_type d)
 
 date (const ymd_type &ymd)
 
year_type year () const
 
month_type month () const
 
day_type day () const
 
day_of_week_type day_of_week () const
 
ymd_type year_month_day () const
 
bool operator< (const date_type &rhs) const
 
bool operator== (const date_type &rhs) const
 
bool is_special () const
 check to see if date is a special value More...
 
bool is_not_a_date () const
 check to see if date is not a value More...
 
bool is_infinity () const
 check to see if date is one of the infinity values More...
 
bool is_pos_infinity () const
 check to see if date is greater than all possible dates More...
 
bool is_neg_infinity () const
 check to see if date is greater than all possible dates More...
 
special_values as_special () const
 return as a special value or a not_special if a normal date More...
 
duration_type operator- (const date_type &d) const
 
date_type operator- (const duration_type &dd) const
 
date_type operator-= (const duration_type &dd)
 
date_rep_type day_count () const
 
date_type operator+ (const duration_type &dd) const
 
date_type operator+= (const duration_type &dd)
 

Protected Member Functions

 date (date_int_type days)
 This is a private constructor which allows for the creation of new dates. More...
 
 date (date_rep_type days)
 

Protected Attributes

date_int_type days_
 

Detailed Description

template<class T, class calendar, class duration_type_>
class boost::date_time::date< T, calendar, duration_type_ >

Representation of timepoint at the one day level resolution.

The date template represents an interface shell for a date class that is based on a year-month-day system such as the gregorian or iso systems. It provides basic operations to enable calculation and comparisons.

Theory

This date representation fundamentally departs from the C tm struct approach. The goal for this type is to provide efficient date operations (add, subtract) and storage (minimize space to represent) in a concrete class. Thus, the date uses a count internally to represent a particular date. The calendar parameter defines the policies for converting the the year-month-day and internal counted form here. Applications that need to perform heavy formatting of the same date repeatedly will perform better by using the year-month-day representation.

Internally the date uses a day number to represent the date. This is a monotonic time representation. This representation allows for fast comparison as well as simplifying the creation of writing numeric operations. Essentially, the internal day number is like adjusted julian day. The adjustment is determined by the Epoch date which is represented as day 1 of the calendar. Day 0 is reserved for negative infinity so that any actual date is automatically greater than negative infinity. When a date is constructed from a date or formatted for output, the appropriate conversions are applied to create the year, month, day representations.

Member Typedef Documentation

template<class T, class calendar, class duration_type_>
typedef calendar boost::date_time::date< T, calendar, duration_type_ >::calendar_type
template<class T, class calendar, class duration_type_>
typedef calendar::date_int_type boost::date_time::date< T, calendar, duration_type_ >::date_int_type
template<class T, class calendar, class duration_type_>
typedef calendar::date_rep_type boost::date_time::date< T, calendar, duration_type_ >::date_rep_type
template<class T, class calendar, class duration_type_>
typedef T boost::date_time::date< T, calendar, duration_type_ >::date_type
template<class T, class calendar, class duration_type_>
typedef calendar::day_of_week_type boost::date_time::date< T, calendar, duration_type_ >::day_of_week_type
template<class T, class calendar, class duration_type_>
typedef calendar::day_type boost::date_time::date< T, calendar, duration_type_ >::day_type
template<class T, class calendar, class duration_type_>
typedef duration_type_ boost::date_time::date< T, calendar, duration_type_ >::duration_type
template<class T, class calendar, class duration_type_>
typedef calendar::month_type boost::date_time::date< T, calendar, duration_type_ >::month_type
template<class T, class calendar, class duration_type_>
typedef calendar::date_traits_type boost::date_time::date< T, calendar, duration_type_ >::traits_type
template<class T, class calendar, class duration_type_>
typedef calendar::year_type boost::date_time::date< T, calendar, duration_type_ >::year_type
template<class T, class calendar, class duration_type_>
typedef calendar::ymd_type boost::date_time::date< T, calendar, duration_type_ >::ymd_type

Constructor & Destructor Documentation

template<class T, class calendar, class duration_type_>
boost::date_time::date< T, calendar, duration_type_ >::date ( year_type  y,
month_type  m,
day_type  d 
)
inline
template<class T, class calendar, class duration_type_>
boost::date_time::date< T, calendar, duration_type_ >::date ( const ymd_type ymd)
inline
template<class T, class calendar, class duration_type_>
boost::date_time::date< T, calendar, duration_type_ >::date ( date_int_type  days)
inlineexplicitprotected

This is a private constructor which allows for the creation of new dates.

It is not exposed to users since that would require class users to understand the inner workings of the date class.

template<class T, class calendar, class duration_type_>
boost::date_time::date< T, calendar, duration_type_ >::date ( date_rep_type  days)
inlineexplicitprotected

Member Function Documentation

template<class T, class calendar, class duration_type_>
special_values boost::date_time::date< T, calendar, duration_type_ >::as_special ( ) const
inline

return as a special value or a not_special if a normal date

Referenced by boost::gregorian::to_tm().

template<class T, class calendar, class duration_type_>
day_type boost::date_time::date< T, calendar, duration_type_ >::day ( ) const
inline
template<class T, class calendar, class duration_type_>
date_rep_type boost::date_time::date< T, calendar, duration_type_ >::day_count ( ) const
inline
template<class T, class calendar, class duration_type_>
day_of_week_type boost::date_time::date< T, calendar, duration_type_ >::day_of_week ( ) const
inline

Referenced by boost::gregorian::to_tm().

template<class T, class calendar, class duration_type_>
bool boost::date_time::date< T, calendar, duration_type_ >::is_infinity ( ) const
inline

check to see if date is one of the infinity values

Referenced by boost::date_time::date< date, gregorian_calendar, date_duration >::is_special().

template<class T, class calendar, class duration_type_>
bool boost::date_time::date< T, calendar, duration_type_ >::is_neg_infinity ( ) const
inline

check to see if date is greater than all possible dates

template<class T, class calendar, class duration_type_>
bool boost::date_time::date< T, calendar, duration_type_ >::is_not_a_date ( ) const
inline

check to see if date is not a value

Referenced by boost::date_time::date< date, gregorian_calendar, date_duration >::is_special().

template<class T, class calendar, class duration_type_>
bool boost::date_time::date< T, calendar, duration_type_ >::is_pos_infinity ( ) const
inline

check to see if date is greater than all possible dates

template<class T, class calendar, class duration_type_>
bool boost::date_time::date< T, calendar, duration_type_ >::is_special ( ) const
inline
template<class T, class calendar, class duration_type_>
month_type boost::date_time::date< T, calendar, duration_type_ >::month ( ) const
inline
template<class T, class calendar, class duration_type_>
date_type boost::date_time::date< T, calendar, duration_type_ >::operator+ ( const duration_type dd) const
inline
template<class T, class calendar, class duration_type_>
date_type boost::date_time::date< T, calendar, duration_type_ >::operator+= ( const duration_type dd)
inline
template<class T, class calendar, class duration_type_>
duration_type boost::date_time::date< T, calendar, duration_type_ >::operator- ( const date_type d) const
inline
template<class T, class calendar, class duration_type_>
date_type boost::date_time::date< T, calendar, duration_type_ >::operator- ( const duration_type dd) const
inline
template<class T, class calendar, class duration_type_>
date_type boost::date_time::date< T, calendar, duration_type_ >::operator-= ( const duration_type dd)
inline
template<class T, class calendar, class duration_type_>
bool boost::date_time::date< T, calendar, duration_type_ >::operator< ( const date_type rhs) const
inline
template<class T, class calendar, class duration_type_>
bool boost::date_time::date< T, calendar, duration_type_ >::operator== ( const date_type rhs) const
inline
template<class T, class calendar, class duration_type_>
year_type boost::date_time::date< T, calendar, duration_type_ >::year ( ) const
inline
template<class T, class calendar, class duration_type_>
ymd_type boost::date_time::date< T, calendar, duration_type_ >::year_month_day ( ) const
inline

Member Data Documentation

template<class T, class calendar, class duration_type_>
date_int_type boost::date_time::date< T, calendar, duration_type_ >::days_
protected

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