Chris@16: #ifndef DATE_TIME_GREGORIAN_CALENDAR_HPP__ Chris@16: #define DATE_TIME_GREGORIAN_CALENDAR_HPP__ Chris@16: Chris@16: /* Copyright (c) 2002,2003 CrystalClear Software, Inc. Chris@16: * Use, modification and distribution is subject to the Chris@16: * Boost Software License, Version 1.0. (See accompanying Chris@16: * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) Chris@16: * Author: Jeff Garland Chris@101: * $Date$ Chris@16: */ Chris@16: Chris@16: Chris@16: namespace boost { Chris@16: namespace date_time { Chris@16: Chris@16: Chris@16: //! An implementation of the Gregorian calendar Chris@16: /*! This is a parameterized implementation of a proleptic Gregorian Calendar that Chris@16: can be used in the creation of date systems or just to perform calculations. Chris@16: All the methods of this class are static functions, so the intent is to Chris@16: never create instances of this class. Chris@16: @param ymd_type_ Struct type representing the year, month, day. The ymd_type must Chris@16: define a of types for the year, month, and day. These types need to be Chris@16: arithmetic types. Chris@16: @param date_int_type_ Underlying type for the date count. Must be an arithmetic type. Chris@16: */ Chris@16: template Chris@16: class gregorian_calendar_base { Chris@16: public: Chris@16: //! define a type a date split into components Chris@16: typedef ymd_type_ ymd_type; Chris@16: //! define a type for representing months Chris@16: typedef typename ymd_type::month_type month_type; Chris@16: //! define a type for representing days Chris@16: typedef typename ymd_type::day_type day_type; Chris@16: //! Type to hold a stand alone year value (eg: 2002) Chris@16: typedef typename ymd_type::year_type year_type; Chris@16: //! Define the integer type to use for internal calculations Chris@16: typedef date_int_type_ date_int_type; Chris@16: Chris@16: Chris@16: static unsigned short day_of_week(const ymd_type& ymd); Chris@16: static int week_number(const ymd_type&ymd); Chris@16: //static unsigned short day_of_year(date_int_type); Chris@16: static date_int_type day_number(const ymd_type& ymd); Chris@16: static date_int_type julian_day_number(const ymd_type& ymd); Chris@16: static date_int_type modjulian_day_number(const ymd_type& ymd); Chris@16: static ymd_type from_day_number(date_int_type); Chris@16: static ymd_type from_julian_day_number(date_int_type); Chris@16: static ymd_type from_modjulian_day_number(date_int_type); Chris@16: static bool is_leap_year(year_type); Chris@16: static unsigned short end_of_month_day(year_type y, month_type m); Chris@16: static ymd_type epoch(); Chris@16: static unsigned short days_in_week(); Chris@16: Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: } } //namespace Chris@16: Chris@16: #ifndef NO_BOOST_DATE_TIME_INLINE Chris@16: #include "boost/date_time/gregorian_calendar.ipp" Chris@16: #endif Chris@16: Chris@16: Chris@16: Chris@16: #endif Chris@16: Chris@16: