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