# Gregorian Calendar

Introduction -- Header -- Functions

Introduction

The class boost::gregorian::gregorian_calendar implements the functions necessary to create the gregorian date system. It converts to the year-month-day form of a date to a day number representation and back.

For most purposes this class is simply accessed by gregorian::date and is not used directly by the user. However, there are useful functions that might be of use such as the end_of_month_day function.

The print month example demonstrates this.

Header

    #include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
    or
    #include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types

Functions

Syntax | Description
--- | ---
Example

    static short day_of_week(ymd_type)

Return the day of the week (0==Sunday, 1==Monday, etc)

See also gregorian::date day_of_week

    static date_int_type day_number(ymd_type)

Convert a ymd_type into a day number. The day number mapping is implementation defined, however the library implements the 1400-01-01 epoch as follows

     date(gregorian_calendar::epoch()).day_number() == 2232400

    static short end_of_month_day(year_type,
                                  month_type)

Given a year and month determine the last day of the month.

    static ymd_type from_day_number(date_int_type)

Convert a day number to a ymd struct.

    static bool is_leap_year(year_type)

Returns true if specified year is a leap year.

    gregorian_calendar::is_leap_year(2000)
    //--> true