greg_year.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef GREG_YEAR_HPP___
  2. #define GREG_YEAR_HPP___
  3. /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
  4. * Use, modification and distribution is subject to the
  5. * Boost Software License, Version 1.0. (See accompanying
  6. * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  7. * Author: Jeff Garland
  8. * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
  9. */
  10. #include "boost/date_time/constrained_value.hpp"
  11. #include <stdexcept>
  12. #include <string>
  13. namespace boost {
  14. namespace gregorian {
  15. //! Exception type for gregorian year
  16. struct bad_year : public std::out_of_range
  17. {
  18. bad_year() :
  19. std::out_of_range(std::string("Year is out of valid range: 1400..10000"))
  20. {}
  21. };
  22. //! Policy class that declares error handling gregorian year type
  23. typedef CV::simple_exception_policy<unsigned short, 1400, 10000, bad_year> greg_year_policies;
  24. //! Generated representation for gregorian year
  25. typedef CV::constrained_value<greg_year_policies> greg_year_rep;
  26. //! Represent a day of the month (range 1900 - 10000)
  27. /*! This small class allows for simple conversion an integer value into
  28. a year for the gregorian calendar. This currently only allows a
  29. range of 1900 to 10000. Both ends of the range are a bit arbitrary
  30. at the moment, but they are the limits of current testing of the
  31. library. As such they may be increased in the future.
  32. */
  33. class greg_year : public greg_year_rep {
  34. public:
  35. greg_year(unsigned short year) : greg_year_rep(year) {}
  36. operator unsigned short() const {return value_;}
  37. private:
  38. };
  39. } } //namespace gregorian
  40. #endif