Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template last_kday_of_month

boost::date_time::last_kday_of_month — Calculate something like Last Sunday of January.

Synopsis

// In header: <boost/date_time/date_generators.hpp>

template<typename date_type> 
class last_kday_of_month :
  public boost::date_time::year_based_generator< date_type >
{
public:
  // types
  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;   

  // construct/copy/destruct
  last_kday_of_month(day_of_week_type, month_type);

  // public member functions
  virtual date_type get_date(year_type) const;
  month_type month() const;
  day_of_week_type day_of_week() const;
  virtual std::string to_string() const;
};

Description

Useful generator functor for finding holidays and daylight savings Get the last day of the month and then calculate the difference to the last previous day.

Template Parameters

  1. typename date_type

    A date class that exports day_of_week, month_type, etc.

last_kday_of_month public construct/copy/destruct

  1. last_kday_of_month(day_of_week_type dow, month_type m);
    Specify the date spec like last 'Sunday' in 'April' spec.

    Parameters:

    dow

    The day of week, eg: Sunday, Monday, etc

    m

    The month of the year, eg: Jan, Feb, Mar, etc

last_kday_of_month public member functions

  1. virtual date_type get_date(year_type year) const;
    Return a concrete date when provided with a year specific year.
  2. month_type month() const;
  3. day_of_week_type day_of_week() const;
  4. virtual std::string to_string() const;
    Returns string suitable for use in POSIX time zone string.

    Returns a string formatted as "M4.5.0" ==> last Sunday in April.


PrevUpHomeNext