1 | #ifndef DATE_TIME_SIMPLE_FORMAT_HPP___ |
2 | #define DATE_TIME_SIMPLE_FORMAT_HPP___ |
3 | |
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 |
9 | * $Date$ |
10 | */ |
11 | |
12 | #include "boost/date_time/parse_format_base.hpp" |
13 | |
14 | namespace boost { |
15 | namespace date_time { |
16 | |
17 | //! Class to provide simple basic formatting rules |
18 | template<class charT> |
19 | class simple_format { |
20 | public: |
21 | |
22 | //! String used printed is date is invalid |
23 | static const charT* not_a_date() |
24 | { |
25 | return "not-a-date-time" ; |
26 | } |
27 | //! String used to for positive infinity value |
28 | static const charT* pos_infinity() |
29 | { |
30 | return "+infinity" ; |
31 | } |
32 | //! String used to for positive infinity value |
33 | static const charT* neg_infinity() |
34 | { |
35 | return "-infinity" ; |
36 | } |
37 | //! Describe month format |
38 | static month_format_spec month_format() |
39 | { |
40 | return month_as_short_string; |
41 | } |
42 | static ymd_order_spec date_order() |
43 | { |
44 | return ymd_order_iso; //YYYY-MM-DD |
45 | } |
46 | //! This format uses '-' to separate date elements |
47 | static bool has_date_sep_chars() |
48 | { |
49 | return true; |
50 | } |
51 | //! Char to sep? |
52 | static charT year_sep_char() |
53 | { |
54 | return '-'; |
55 | } |
56 | //! char between year-month |
57 | static charT month_sep_char() |
58 | { |
59 | return '-'; |
60 | } |
61 | //! Char to separate month-day |
62 | static charT day_sep_char() |
63 | { |
64 | return '-'; |
65 | } |
66 | //! char between date-hours |
67 | static charT hour_sep_char() |
68 | { |
69 | return ' '; |
70 | } |
71 | //! char between hour and minute |
72 | static charT minute_sep_char() |
73 | { |
74 | return ':'; |
75 | } |
76 | //! char for second |
77 | static charT second_sep_char() |
78 | { |
79 | return ':'; |
80 | } |
81 | |
82 | }; |
83 | |
84 | #ifndef BOOST_NO_STD_WSTRING |
85 | |
86 | //! Specialization of formmating rules for wchar_t |
87 | template<> |
88 | class simple_format<wchar_t> { |
89 | public: |
90 | |
91 | //! String used printed is date is invalid |
92 | static const wchar_t* not_a_date() |
93 | { |
94 | return L"not-a-date-time" ; |
95 | } |
96 | //! String used to for positive infinity value |
97 | static const wchar_t* pos_infinity() |
98 | { |
99 | return L"+infinity" ; |
100 | } |
101 | //! String used to for positive infinity value |
102 | static const wchar_t* neg_infinity() |
103 | { |
104 | return L"-infinity" ; |
105 | } |
106 | //! Describe month format |
107 | static month_format_spec month_format() |
108 | { |
109 | return month_as_short_string; |
110 | } |
111 | static ymd_order_spec date_order() |
112 | { |
113 | return ymd_order_iso; //YYYY-MM-DD |
114 | } |
115 | //! This format uses '-' to separate date elements |
116 | static bool has_date_sep_chars() |
117 | { |
118 | return true; |
119 | } |
120 | //! Char to sep? |
121 | static wchar_t year_sep_char() |
122 | { |
123 | return '-'; |
124 | } |
125 | //! char between year-month |
126 | static wchar_t month_sep_char() |
127 | { |
128 | return '-'; |
129 | } |
130 | //! Char to separate month-day |
131 | static wchar_t day_sep_char() |
132 | { |
133 | return '-'; |
134 | } |
135 | //! char between date-hours |
136 | static wchar_t hour_sep_char() |
137 | { |
138 | return ' '; |
139 | } |
140 | //! char between hour and minute |
141 | static wchar_t minute_sep_char() |
142 | { |
143 | return ':'; |
144 | } |
145 | //! char for second |
146 | static wchar_t second_sep_char() |
147 | { |
148 | return ':'; |
149 | } |
150 | |
151 | }; |
152 | |
153 | #endif // BOOST_NO_STD_WSTRING |
154 | } } //namespace date_time |
155 | |
156 | |
157 | |
158 | |
159 | #endif |
160 | |