1 #ifndef ISO_FORMAT_HPP___
2 #define ISO_FORMAT_HPP___
4 /* Copyright (c) 2002,2003 CrystalClear Software, Inc.
5 * Use, modification and distribution is subject to the
6 * Boost Software License, Version 1.0. (See accompanying
7 * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
8 * Author: Jeff Garland, Bart Garst
12 #include "boost/date_time/parse_format_base.hpp"
17 //! Class to provide common iso formatting spec
19 class iso_format_base {
21 //! Describe month format -- its an integer in iso format
22 static month_format_spec month_format()
24 return month_as_integer;
27 //! String used printed is date is invalid
28 static const charT* not_a_date()
30 return "not-a-date-time";
32 //! String used to for positive infinity value
33 static const charT* pos_infinity()
37 //! String used to for positive infinity value
38 static const charT* neg_infinity()
43 //! ISO char for a year -- used in durations
44 static charT year_sep_char()
48 //! ISO char for a month
49 static charT month_sep_char()
53 //! ISO char for a day
54 static charT day_sep_char()
59 static charT hour_sep_char()
64 static charT minute_sep_char()
69 static charT second_sep_char()
73 //! ISO char for a period
74 static charT period_start_char()
78 //! Used in time in mixed strings to set start of time
79 static charT time_start_char()
84 //! Used in mixed strings to identify start of a week number
85 static charT week_start_char()
90 //! Separators for periods
91 static charT period_sep_char()
95 //! Separator for hh:mm:ss
96 static charT time_sep_char()
100 //! Preferred Separator for hh:mm:ss,decimal_fraction
101 static charT fractional_time_sep_char()
106 static bool is_component_sep(charT sep)
115 case 'D':return true;
121 static bool is_fractional_time_sep(charT sep)
125 case '.': return true;
126 default: return false;
129 static bool is_timezone_sep(charT sep)
133 case '-': return true;
134 default: return false;
137 static charT element_sep_char()
144 #ifndef BOOST_NO_STD_WSTRING
146 //! Class to provide common iso formatting spec
148 class iso_format_base<wchar_t> {
150 //! Describe month format -- its an integer in iso format
151 static month_format_spec month_format()
153 return month_as_integer;
156 //! String used printed is date is invalid
157 static const wchar_t* not_a_date()
159 return L"not-a-date-time";
161 //! String used to for positive infinity value
162 static const wchar_t* pos_infinity()
166 //! String used to for positive infinity value
167 static const wchar_t* neg_infinity()
172 //! ISO char for a year -- used in durations
173 static wchar_t year_sep_char()
177 //! ISO char for a month
178 static wchar_t month_sep_char()
182 //! ISO char for a day
183 static wchar_t day_sep_char()
188 static wchar_t hour_sep_char()
193 static wchar_t minute_sep_char()
198 static wchar_t second_sep_char()
202 //! ISO char for a period
203 static wchar_t period_start_char()
207 //! Used in time in mixed strings to set start of time
208 static wchar_t time_start_char()
213 //! Used in mixed strings to identify start of a week number
214 static wchar_t week_start_char()
219 //! Separators for periods
220 static wchar_t period_sep_char()
224 //! Separator for hh:mm:ss
225 static wchar_t time_sep_char()
229 //! Preferred Separator for hh:mm:ss,decimal_fraction
230 static wchar_t fractional_time_sep_char()
235 static bool is_component_sep(wchar_t sep)
244 case 'D':return true;
250 static bool is_fractional_time_sep(wchar_t sep)
254 case '.': return true;
255 default: return false;
258 static bool is_timezone_sep(wchar_t sep)
262 case '-': return true;
263 default: return false;
266 static wchar_t element_sep_char()
273 #endif // BOOST_NO_STD_WSTRING
275 //! Format description for iso normal YYYYMMDD
276 template<class charT>
277 class iso_format : public iso_format_base<charT> {
279 //! The ios standard format doesn't use char separators
280 static bool has_date_sep_chars()
286 //! Extended format uses seperators YYYY-MM-DD
287 template<class charT>
288 class iso_extended_format : public iso_format_base<charT> {
290 //! Extended format needs char separators
291 static bool has_date_sep_chars()
298 } } //namespace date_time