Chris@16
|
1 #ifndef GREG_WEEKDAY_HPP___
|
Chris@16
|
2 #define GREG_WEEKDAY_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, Bart Garst
|
Chris@101
|
9 * $Date$
|
Chris@16
|
10 */
|
Chris@16
|
11
|
Chris@16
|
12 #include "boost/date_time/constrained_value.hpp"
|
Chris@16
|
13 #include "boost/date_time/date_defs.hpp"
|
Chris@16
|
14 #include "boost/date_time/compiler_config.hpp"
|
Chris@16
|
15 #include <stdexcept>
|
Chris@16
|
16 #include <string>
|
Chris@16
|
17
|
Chris@16
|
18 namespace boost {
|
Chris@16
|
19 namespace gregorian {
|
Chris@16
|
20
|
Chris@16
|
21 //bring enum values into the namespace
|
Chris@16
|
22 using date_time::Sunday;
|
Chris@16
|
23 using date_time::Monday;
|
Chris@16
|
24 using date_time::Tuesday;
|
Chris@16
|
25 using date_time::Wednesday;
|
Chris@16
|
26 using date_time::Thursday;
|
Chris@16
|
27 using date_time::Friday;
|
Chris@16
|
28 using date_time::Saturday;
|
Chris@16
|
29
|
Chris@16
|
30
|
Chris@16
|
31 //! Exception that flags that a weekday number is incorrect
|
Chris@16
|
32 struct bad_weekday : public std::out_of_range
|
Chris@16
|
33 {
|
Chris@16
|
34 bad_weekday() : std::out_of_range(std::string("Weekday is out of range 0..6")) {}
|
Chris@16
|
35 };
|
Chris@16
|
36 typedef CV::simple_exception_policy<unsigned short, 0, 6, bad_weekday> greg_weekday_policies;
|
Chris@16
|
37 typedef CV::constrained_value<greg_weekday_policies> greg_weekday_rep;
|
Chris@16
|
38
|
Chris@16
|
39
|
Chris@16
|
40 //! Represent a day within a week (range 0==Sun to 6==Sat)
|
Chris@16
|
41 class BOOST_DATE_TIME_DECL greg_weekday : public greg_weekday_rep {
|
Chris@16
|
42 public:
|
Chris@16
|
43 typedef boost::date_time::weekdays weekday_enum;
|
Chris@16
|
44 greg_weekday(unsigned short day_of_week_num) :
|
Chris@16
|
45 greg_weekday_rep(day_of_week_num)
|
Chris@16
|
46 {}
|
Chris@16
|
47
|
Chris@16
|
48 unsigned short as_number() const {return value_;}
|
Chris@16
|
49 const char* as_short_string() const;
|
Chris@16
|
50 const char* as_long_string() const;
|
Chris@16
|
51 #ifndef BOOST_NO_STD_WSTRING
|
Chris@16
|
52 const wchar_t* as_short_wstring() const;
|
Chris@16
|
53 const wchar_t* as_long_wstring() const;
|
Chris@16
|
54 #endif // BOOST_NO_STD_WSTRING
|
Chris@16
|
55 weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
|
Chris@16
|
56
|
Chris@16
|
57
|
Chris@16
|
58 };
|
Chris@16
|
59
|
Chris@16
|
60
|
Chris@16
|
61
|
Chris@16
|
62 } } //namespace gregorian
|
Chris@16
|
63
|
Chris@16
|
64
|
Chris@16
|
65
|
Chris@16
|
66 #endif
|