1 | #ifndef DATE_TIME_GREGORIAN_CALENDAR_HPP__ |
2 | #define DATE_TIME_GREGORIAN_CALENDAR_HPP__ |
3 | |
4 | /* Copyright (c) 2002,2003 CrystalClear Software, Inc. |
5 | * Use, modification and distribution is subject to the |
6 | * Boost Software License, Version 1.0. (See accompanying |
7 | * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) |
8 | * Author: Jeff Garland |
9 | * $Date$ |
10 | */ |
11 | |
12 | #include <boost/date_time/compiler_config.hpp> |
13 | |
14 | namespace boost { |
15 | namespace date_time { |
16 | |
17 | |
18 | //! An implementation of the Gregorian calendar |
19 | /*! This is a parameterized implementation of a proleptic Gregorian Calendar that |
20 | can be used in the creation of date systems or just to perform calculations. |
21 | All the methods of this class are static functions, so the intent is to |
22 | never create instances of this class. |
23 | @tparam ymd_type_ Struct type representing the year, month, day. The ymd_type must |
24 | define a of types for the year, month, and day. These types need to be |
25 | arithmetic types. |
26 | @tparam date_int_type_ Underlying type for the date count. Must be an arithmetic type. |
27 | */ |
28 | template<typename ymd_type_, typename date_int_type_> |
29 | class BOOST_SYMBOL_VISIBLE gregorian_calendar_base { |
30 | public: |
31 | //! define a type a date split into components |
32 | typedef ymd_type_ ymd_type; |
33 | //! define a type for representing months |
34 | typedef typename ymd_type::month_type month_type; |
35 | //! define a type for representing days |
36 | typedef typename ymd_type::day_type day_type; |
37 | //! Type to hold a stand alone year value (eg: 2002) |
38 | typedef typename ymd_type::year_type year_type; |
39 | //! Define the integer type to use for internal calculations |
40 | typedef date_int_type_ date_int_type; |
41 | |
42 | |
43 | static BOOST_CXX14_CONSTEXPR unsigned short day_of_week(const ymd_type& ymd); |
44 | static BOOST_CXX14_CONSTEXPR int week_number(const ymd_type&ymd); |
45 | static BOOST_CXX14_CONSTEXPR date_int_type day_number(const ymd_type& ymd); |
46 | static BOOST_CXX14_CONSTEXPR date_int_type julian_day_number(const ymd_type& ymd); |
47 | static BOOST_CXX14_CONSTEXPR date_int_type modjulian_day_number(const ymd_type& ymd); |
48 | static BOOST_CXX14_CONSTEXPR ymd_type from_day_number(date_int_type); |
49 | static BOOST_CXX14_CONSTEXPR ymd_type from_julian_day_number(date_int_type); |
50 | static BOOST_CXX14_CONSTEXPR ymd_type from_modjulian_day_number(date_int_type); |
51 | static BOOST_CXX14_CONSTEXPR bool is_leap_year(year_type); |
52 | static BOOST_CXX14_CONSTEXPR unsigned short end_of_month_day(year_type y, month_type m); |
53 | static BOOST_CXX14_CONSTEXPR ymd_type epoch(); |
54 | static BOOST_CXX14_CONSTEXPR unsigned short days_in_week(); |
55 | |
56 | }; |
57 | |
58 | |
59 | |
60 | } } //namespace |
61 | |
62 | #include "boost/date_time/gregorian_calendar.ipp" |
63 | |
64 | |
65 | |
66 | |
67 | #endif |
68 | |
69 | |
70 | |