1
/* Copyright (c) 2002-2005 CrystalClear Software, Inc.
2
* Use, modification and distribution is subject to the
3
* Boost Software License, Version 1.0. (See accompanying
4
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
5
* Author: Jeff Garland, Bart Garst
6
* $Date: 2012-09-30 16:25:22 -0700 (Sun, 30 Sep 2012) $
11
#ifndef BOOST_DATE_TIME_SOURCE
12
#define BOOST_DATE_TIME_SOURCE
14
#include "boost/date_time/gregorian/greg_month.hpp"
15
#include "boost/date_time/gregorian/greg_facet.hpp"
16
#include "boost/date_time/date_format_simple.hpp"
17
#include "boost/date_time/compiler_config.hpp"
18
#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS)
19
#include "boost/date_time/gregorian/formatters_limited.hpp"
21
#include "boost/date_time/gregorian/formatters.hpp"
23
#include "boost/date_time/date_parsing.hpp"
24
#include "boost/date_time/gregorian/parsers.hpp"
26
#include "greg_names.hpp"
30
/*! Returns a shared pointer to a map of Month strings & numbers.
31
* Strings are both full names and abbreviations.
32
* Ex. ("jan",1), ("february",2), etc...
33
* Note: All characters are lowercase - for case insensitivity
35
greg_month::month_map_ptr_type greg_month::get_month_map_ptr()
37
static month_map_ptr_type month_map_ptr(new greg_month::month_map_type());
39
if(month_map_ptr->empty()) {
41
for(unsigned short i = 1; i <= 12; ++i) {
42
greg_month m(static_cast<month_enum>(i));
43
s = m.as_long_string();
44
s = date_time::convert_to_lower(s);
45
month_map_ptr->insert(std::make_pair(s, i));
46
s = m.as_short_string();
47
s = date_time::convert_to_lower(s);
48
month_map_ptr->insert(std::make_pair(s, i));
55
//! Returns 3 char english string for the month ex: Jan, Feb, Mar, Apr
57
greg_month::as_short_string() const
59
return short_month_names[value_-1];
62
//! Returns full name of month as string in english ex: January, February
64
greg_month::as_long_string() const
66
return long_month_names[value_-1];
69
//! Return special_value from string argument
70
/*! Return special_value from string argument. If argument is
71
* not one of the special value names (defined in names.hpp),
72
* return 'not_special' */
73
special_values special_value_from_string(const std::string& s) {
74
short i = date_time::find_match(special_value_names,
76
date_time::NumSpecialValues,
78
if(i >= date_time::NumSpecialValues) { // match not found
82
return static_cast<special_values>(i);
87
#ifndef BOOST_NO_STD_WSTRING
88
//! Returns 3 wchar_t english string for the month ex: Jan, Feb, Mar, Apr
90
greg_month::as_short_wstring() const
92
return w_short_month_names[value_-1];
95
//! Returns full name of month as wchar_t string in english ex: January, February
97
greg_month::as_long_wstring() const
99
return w_long_month_names[value_-1];
101
#endif // BOOST_NO_STD_WSTRING
103
#ifndef BOOST_DATE_TIME_NO_LOCALE
104
/*! creates an all_date_names_put object with the correct set of names.
105
* This function is only called in the event of an exception where
106
* the imbued locale containing the needed facet is for some reason
110
boost::date_time::all_date_names_put<greg_facet_config, char>*
111
create_facet_def(char /*type*/)
114
boost::date_time::all_date_names_put<greg_facet_config, char> facet_def;
116
return new facet_def(short_month_names,
123
//! generates a locale with the set of gregorian name-strings of type char*
124
BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, char /*type*/){
125
typedef boost::date_time::all_date_names_put<greg_facet_config, char> facet_def;
126
return std::locale(loc, new facet_def(short_month_names,
134
#ifndef BOOST_NO_STD_WSTRING
135
/*! creates an all_date_names_put object with the correct set of names.
136
* This function is only called in the event of an exception where
137
* the imbued locale containing the needed facet is for some reason
141
boost::date_time::all_date_names_put<greg_facet_config, wchar_t>*
142
create_facet_def(wchar_t /*type*/)
145
boost::date_time::all_date_names_put<greg_facet_config,wchar_t> facet_def;
147
return new facet_def(w_short_month_names,
149
w_special_value_names,
150
w_short_weekday_names,
151
w_long_weekday_names);
154
//! generates a locale with the set of gregorian name-strings of type wchar_t*
155
BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, wchar_t /*type*/){
156
typedef boost::date_time::all_date_names_put<greg_facet_config, wchar_t> facet_def;
157
return std::locale(loc, new facet_def(w_short_month_names,
159
w_special_value_names,
160
w_short_weekday_names,
161
w_long_weekday_names)
164
#endif // BOOST_NO_STD_WSTRING
165
#endif // BOOST_DATE_TIME_NO_LOCALE
167
} } //namespace gregorian