Chris@16: #ifndef GREG_WEEKDAY_HPP___ Chris@16: #define GREG_WEEKDAY_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, Bart Garst Chris@101: * $Date$ Chris@16: */ Chris@16: Chris@16: #include "boost/date_time/constrained_value.hpp" Chris@16: #include "boost/date_time/date_defs.hpp" Chris@16: #include "boost/date_time/compiler_config.hpp" Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace gregorian { Chris@16: Chris@16: //bring enum values into the namespace Chris@16: using date_time::Sunday; Chris@16: using date_time::Monday; Chris@16: using date_time::Tuesday; Chris@16: using date_time::Wednesday; Chris@16: using date_time::Thursday; Chris@16: using date_time::Friday; Chris@16: using date_time::Saturday; Chris@16: Chris@16: Chris@16: //! Exception that flags that a weekday number is incorrect Chris@16: struct bad_weekday : public std::out_of_range Chris@16: { Chris@16: bad_weekday() : std::out_of_range(std::string("Weekday is out of range 0..6")) {} Chris@16: }; Chris@16: typedef CV::simple_exception_policy greg_weekday_policies; Chris@16: typedef CV::constrained_value greg_weekday_rep; Chris@16: Chris@16: Chris@16: //! Represent a day within a week (range 0==Sun to 6==Sat) Chris@16: class BOOST_DATE_TIME_DECL greg_weekday : public greg_weekday_rep { Chris@16: public: Chris@16: typedef boost::date_time::weekdays weekday_enum; Chris@16: greg_weekday(unsigned short day_of_week_num) : Chris@16: greg_weekday_rep(day_of_week_num) Chris@16: {} Chris@16: Chris@16: unsigned short as_number() const {return value_;} Chris@16: const char* as_short_string() const; Chris@16: const char* as_long_string() const; Chris@16: #ifndef BOOST_NO_STD_WSTRING Chris@16: const wchar_t* as_short_wstring() const; Chris@16: const wchar_t* as_long_wstring() const; Chris@16: #endif // BOOST_NO_STD_WSTRING Chris@16: weekday_enum as_enum() const {return static_cast(value_);} Chris@16: Chris@16: Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: } } //namespace gregorian Chris@16: Chris@16: Chris@16: Chris@16: #endif