![]() |
Home | Libraries | People | FAQ | More |
boost::date_time::format_date_parser — Class with generic date parsing using a format string.
// In header: <boost/date_time/format_date_parser.hpp> template<typename date_type, typename charT> class format_date_parser { public: // types typedef charT > ; typedef charT > ; typedef charT > ; typedef ; typedef ; typedef ; typedef ; typedef ; typedef ; typedef ; typedef string_parse_tree< charT > ; typedef ; typedef charT > > ; // construct/copy/destruct (const , const , const , const , const ); (const , const ); (const format_date_parser< charT > &); // public member functions () ; void (); void (const ); void (const ); void (const ); void (const ); (const , const , const special_values_parser< charT > &) ; (charT > &, charT > &, const special_values_parser< charT > &) ; (charT > &, charT > &, , const special_values_parser< charT > &) ; (charT > &, charT > &, ) ; (charT > &, charT > &, , ) ; (charT > &, charT > &) ; (charT > &, charT > &) ; (charT > &, charT > &, ) ; (charT > &, charT > &, , ) ; (charT > &, charT > &, ) ; (charT > &, charT > &, , ) ; };
The following is the set of recognized format specifiers
a - Short weekday name
A - Long weekday name
b - Abbreviated month name
B - Full month name
d - Day of the month as decimal 01 to 31
j - Day of year as decimal from 001 to 366
m - Month name as a decimal 01 to 12
U - Week number 00 to 53 with first Sunday as the first day of week 1?
w - Weekday as decimal number 0 to 6 where Sunday == 0
W - Week number 00 to 53 where Monday is first day of week 1
x - facet default date representation
y - Year without the century - eg: 04 for 2004
Y - Year with century
The weekday specifiers (a and A) do not add to the date construction, but they provide a way to skip over the weekday names for formats that provide them.
todo – Another interesting feature that this approach could provide is an option to fill in any missing fields with the current values from the clock. So if you have m-d the parser would detect the missing year value and fill it in using the clock.
todo – What to do with the x. x in the classic facet is just bad...
format_date_parser
public
construct/copy/destruct(const format_str, const month_short_names, const month_long_names, const weekday_short_names, const weekday_long_names);
(const format_str, const locale);
(const format_date_parser< charT > & fdp);
format_date_parser
public member functions() ;
void ( format_str);
void (const month_names);
void (const month_names);
void (const weekday_names);
void (const weekday_names);
(const value, const format_str, const special_values_parser< charT > & sv_parser) ;
(charT > & sitr, charT > & stream_end, const special_values_parser< charT > & sv_parser) ;
(charT > & sitr, charT > & stream_end, format_str, const special_values_parser< charT > & sv_parser) ;
Of all the objects that the format_date_parser
can parse, only a date can be a special value. Therefore, only parse_date checks for special_values.
(charT > & sitr, charT > & stream_end, format_str) ;Throws bad_month if unable to parse.
(charT > & sitr, charT > & stream_end, format_str, mr) ;Throws bad_month if unable to parse.
(charT > & sitr, charT > & stream_end) ;Expects 1 or 2 digits 1-31. Throws bad_day_of_month if unable to parse.
(charT > & sitr, charT > & stream_end) ;Expects 2 digits 01-31. Throws bad_day_of_month if unable to parse.
(charT > & sitr, charT > & stream_end, format_str) ;
(charT > & sitr, charT > & stream_end, format_str, mr) ;
(charT > & sitr, charT > & stream_end, format_str) ;throws bad_year if unable to parse
(charT > & sitr, charT > & stream_end, format_str, mr) ;throws bad_year if unable to parse