![]() |
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 ; typedef ; typedef ; typedef ; typedef ; typedef ; typedef ; typedef ; typedef ; typedef ; typedef string_parse_tree< ; typedef parse_tree_type::parse_match_result_type ; typedef ; // construct/copy/destruct (, , , , ); (, ); (format_date_parser< ); // public member functions () ; (); (); (); (); (); (, , special_values_parser< ) ; (, , special_values_parser< ) ; (, , , special_values_parser< ) ; (, , ) ; (, , , match_results &) ; (, ) ; (, ) ; (, , ) ; (, , , match_results &) ; (, , ) ; (, , , match_results &) ; };
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( format_str, month_short_names, month_long_names, weekday_short_names, weekday_long_names);
( format_str, locale);
(format_date_parser< fdp);
format_date_parser
public member functions() ;
( format_str);
( month_names);
( month_names);
( weekday_names);
( weekday_names);
( value, format_str, special_values_parser< sv_parser) ;
( sitr, stream_end, special_values_parser< sv_parser) ;
( sitr, stream_end, format_str, special_values_parser< 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.
( sitr, stream_end, format_str) ;Throws bad_month if unable to parse.
( sitr, stream_end, format_str, match_results & mr) ;Throws bad_month if unable to parse.
( sitr, stream_end) ;Expects 1 or 2 digits 1-31. Throws bad_day_of_month if unable to parse.
( sitr, stream_end) ;Expects 2 digits 01-31. Throws bad_day_of_month if unable to parse.
( sitr, stream_end, format_str) ;
( sitr, stream_end, format_str, match_results & mr) ;
( sitr, stream_end, format_str) ;throws bad_year if unable to parse
( sitr, stream_end, format_str, match_results & mr) ;throws bad_year if unable to parse