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::nth_kday_of_month< date_type > Class Template Reference

Useful generator functor for finding holidays. More...

#include <date_generators.hpp>

Inheritance diagram for boost::date_time::nth_kday_of_month< date_type >:
Collaboration diagram for boost::date_time::nth_kday_of_month< date_type >:

Public Types

enum  week_num {
  first =1,
  second,
  third,
  fourth,
  fifth
}
 
typedef date_type::calendar_type calendar_type
 
typedef
calendar_type::day_of_week_type 
day_of_week_type
 
typedef calendar_type::month_type month_type
 
typedef calendar_type::year_type year_type
 
typedef date_type::duration_type duration_type
 

Public Member Functions

 nth_kday_of_month (week_num week_no, day_of_week_type dow, month_type m)
 
date_type get_date (year_type y) const
 Return a concrete date when provided with a year specific year. More...
 
month_type month () const
 
week_num nth_week () const
 
day_of_week_type day_of_week () const
 
const char * nth_week_as_str () const
 
virtual std::string to_string () const
 Returns string suitable for use in POSIX time zone string. More...
 

Detailed Description

template<class date_type>
class boost::date_time::nth_kday_of_month< date_type >

Useful generator functor for finding holidays.

Based on the idea in Cal. Calc. for finding holidays that are the 'first Monday of September'. When instantiated with 'fifth' kday of month, the result will be the last kday of month which can be the fourth or fifth depending on the structure of the month.

The algorithm here basically guesses for the first day of the month. Then finds the first day of the correct type. That is, if the first of the month is a Tuesday and it needs Wenesday then we simply increment by a day and then we can add the length of a week until we get to the 'nth kday'. There are probably more efficient algorithms based on using a mod 7, but this one works reasonably well for basic applications.

Member Typedef Documentation

template<class date_type >
typedef date_type::calendar_type boost::date_time::nth_kday_of_month< date_type >::calendar_type
template<class date_type >
typedef calendar_type::day_of_week_type boost::date_time::nth_kday_of_month< date_type >::day_of_week_type
template<class date_type >
typedef date_type::duration_type boost::date_time::nth_kday_of_month< date_type >::duration_type
template<class date_type >
typedef calendar_type::month_type boost::date_time::nth_kday_of_month< date_type >::month_type
template<class date_type >
typedef calendar_type::year_type boost::date_time::nth_kday_of_month< date_type >::year_type

Member Enumeration Documentation

template<class date_type >
enum boost::date_time::nth_kday_of_month::week_num
Enumerator
first 
second 
third 
fourth 
fifth 

Constructor & Destructor Documentation

template<class date_type >
boost::date_time::nth_kday_of_month< date_type >::nth_kday_of_month ( week_num  week_no,
day_of_week_type  dow,
month_type  m 
)
inline

Member Function Documentation

template<class date_type >
const char* boost::date_time::nth_kday_of_month< date_type >::nth_week_as_str ( ) const
inline
template<class date_type >
virtual std::string boost::date_time::nth_kday_of_month< date_type >::to_string ( ) const
inlinevirtual

Returns string suitable for use in POSIX time zone string.

Returns a string formatted as "M4.3.0" ==> 3rd Sunday in April.

Implements boost::date_time::year_based_generator< date_type >.


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