File indexing completed on 2025-01-30 09:35:19
0001 #ifndef GREG_WEEKDAY_HPP___
0002 #define GREG_WEEKDAY_HPP___
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <boost/date_time/constrained_value.hpp>
0013 #include <boost/date_time/date_defs.hpp>
0014 #include <boost/date_time/compiler_config.hpp>
0015 #include <stdexcept>
0016 #include <string>
0017
0018 namespace boost {
0019 namespace gregorian {
0020
0021
0022 using date_time::Sunday;
0023 using date_time::Monday;
0024 using date_time::Tuesday;
0025 using date_time::Wednesday;
0026 using date_time::Thursday;
0027 using date_time::Friday;
0028 using date_time::Saturday;
0029
0030
0031
0032 struct BOOST_SYMBOL_VISIBLE bad_weekday : public std::out_of_range
0033 {
0034 bad_weekday() : std::out_of_range(std::string("Weekday is out of range 0..6")) {}
0035 };
0036 typedef CV::simple_exception_policy<unsigned short, 0, 6, bad_weekday> greg_weekday_policies;
0037 typedef CV::constrained_value<greg_weekday_policies> greg_weekday_rep;
0038
0039
0040
0041 class BOOST_SYMBOL_VISIBLE greg_weekday : public greg_weekday_rep {
0042 public:
0043 typedef boost::date_time::weekdays weekday_enum;
0044 BOOST_CXX14_CONSTEXPR greg_weekday(value_type day_of_week_num) :
0045 greg_weekday_rep(day_of_week_num)
0046 {}
0047
0048 BOOST_CXX14_CONSTEXPR value_type as_number() const {return value_;}
0049 BOOST_CXX14_CONSTEXPR weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
0050
0051
0052 const char* as_short_string() const
0053 {
0054 static const char* const short_weekday_names[]
0055 = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
0056
0057 return short_weekday_names[value_];
0058 }
0059
0060
0061 const char* as_long_string() const
0062 {
0063 static const char* const long_weekday_names[]
0064 = {"Sunday","Monday","Tuesday","Wednesday", "Thursday", "Friday", "Saturday"};
0065
0066 return long_weekday_names[value_];
0067 }
0068
0069
0070 #ifndef BOOST_NO_STD_WSTRING
0071
0072
0073 const wchar_t* as_short_wstring() const
0074 {
0075 static const wchar_t* const w_short_weekday_names[]={L"Sun", L"Mon", L"Tue",
0076 L"Wed", L"Thu", L"Fri", L"Sat"};
0077 return w_short_weekday_names[value_];
0078 }
0079
0080
0081 const wchar_t* as_long_wstring() const
0082 {
0083 static const wchar_t* const w_long_weekday_names[]= {L"Sunday",L"Monday",L"Tuesday",
0084 L"Wednesday", L"Thursday",
0085 L"Friday", L"Saturday"};
0086 return w_long_weekday_names[value_];
0087 }
0088
0089 #endif
0090
0091
0092 };
0093
0094
0095
0096 } }
0097
0098
0099
0100 #endif