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 a snapshot of the develop branch, built from commit cf7c0df373.
PrevUpHomeNext

Class template gregorian_calendar_base

boost::date_time::gregorian_calendar_base — An implementation of the Gregorian calendar.

Synopsis

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

template<typename ymd_type_, typename date_int_type_> 
class gregorian_calendar_base {
public:
  // types
  typedef ymd_type_            ymd_type;       // define a type a date split into components 
  typedef ymd_type::month_type month_type;     // define a type for representing months 
  typedef ymd_type::day_type   day_type;       // define a type for representing days 
  typedef ymd_type::year_type  year_type;      // Type to hold a stand alone year value (eg: 2002) 
  typedef date_int_type_       date_int_type;  // Define the integer type to use for internal calculations. 

  // public static functions
  static BOOST_CXX14_CONSTEXPR unsigned short day_of_week(const ymd_type &);
  static BOOST_CXX14_CONSTEXPR int week_number(const ymd_type &);
  static BOOST_CXX14_CONSTEXPR date_int_type day_number(const ymd_type &);
  static BOOST_CXX14_CONSTEXPR date_int_type 
  julian_day_number(const ymd_type &);
  static BOOST_CXX14_CONSTEXPR date_int_type 
  modjulian_day_number(const ymd_type &);
  static BOOST_CXX14_CONSTEXPR ymd_type from_day_number(date_int_type);
  static BOOST_CXX14_CONSTEXPR ymd_type from_julian_day_number(date_int_type);
  static BOOST_CXX14_CONSTEXPR ymd_type 
  from_modjulian_day_number(date_int_type);
  static BOOST_CXX14_CONSTEXPR bool is_leap_year(year_type);
  static BOOST_CXX14_CONSTEXPR unsigned short 
  end_of_month_day(year_type, month_type);
  static BOOST_CXX14_CONSTEXPR ymd_type epoch();
  static BOOST_CXX14_CONSTEXPR unsigned short days_in_week();
};

Description

This is a parameterized implementation of a proleptic Gregorian Calendar that can be used in the creation of date systems or just to perform calculations. All the methods of this class are static functions, so the intent is to never create instances of this class.

Template Parameters

  1. typename ymd_type_

    Struct type representing the year, month, day. The ymd_type must define a of types for the year, month, and day. These types need to be arithmetic types.

  2. typename date_int_type_

    Underlying type for the date count. Must be an arithmetic type.

gregorian_calendar_base public static functions

  1. static BOOST_CXX14_CONSTEXPR unsigned short day_of_week(const ymd_type & ymd);
  2. static BOOST_CXX14_CONSTEXPR int week_number(const ymd_type & ymd);
  3. static BOOST_CXX14_CONSTEXPR date_int_type day_number(const ymd_type & ymd);
  4. static BOOST_CXX14_CONSTEXPR date_int_type 
    julian_day_number(const ymd_type & ymd);
  5. static BOOST_CXX14_CONSTEXPR date_int_type 
    modjulian_day_number(const ymd_type & ymd);
  6. static BOOST_CXX14_CONSTEXPR ymd_type from_day_number(date_int_type);
  7. static BOOST_CXX14_CONSTEXPR ymd_type from_julian_day_number(date_int_type);
  8. static BOOST_CXX14_CONSTEXPR ymd_type from_modjulian_day_number(date_int_type);
  9. static BOOST_CXX14_CONSTEXPR bool is_leap_year(year_type);
  10. static BOOST_CXX14_CONSTEXPR unsigned short 
    end_of_month_day(year_type y, month_type m);
  11. static BOOST_CXX14_CONSTEXPR ymd_type epoch();
  12. static BOOST_CXX14_CONSTEXPR unsigned short days_in_week();

PrevUpHomeNext