Chris@16: #ifndef GREG_YEAR_HPP___ Chris@16: #define GREG_YEAR_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: #include "boost/date_time/constrained_value.hpp" Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace gregorian { Chris@16: Chris@16: //! Exception type for gregorian year Chris@16: struct bad_year : public std::out_of_range Chris@16: { Chris@16: bad_year() : Chris@16: std::out_of_range(std::string("Year is out of valid range: 1400..10000")) Chris@16: {} Chris@16: }; Chris@16: //! Policy class that declares error handling gregorian year type Chris@16: typedef CV::simple_exception_policy greg_year_policies; Chris@16: Chris@16: //! Generated representation for gregorian year Chris@16: typedef CV::constrained_value greg_year_rep; Chris@16: Chris@16: //! Represent a day of the month (range 1900 - 10000) Chris@16: /*! This small class allows for simple conversion an integer value into Chris@16: a year for the gregorian calendar. This currently only allows a Chris@16: range of 1900 to 10000. Both ends of the range are a bit arbitrary Chris@16: at the moment, but they are the limits of current testing of the Chris@16: library. As such they may be increased in the future. Chris@16: */ Chris@16: class greg_year : public greg_year_rep { Chris@16: public: Chris@16: greg_year(unsigned short year) : greg_year_rep(year) {} Chris@16: operator unsigned short() const {return value_;} Chris@16: private: Chris@16: Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: } } //namespace gregorian Chris@16: Chris@16: Chris@16: Chris@16: #endif