Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template format_date_parser

boost::date_time::format_date_parser — Class with generic date parsing using a format string.

Synopsis

// 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 > &, , 
                       ) ;
};

Description

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

  1. (const  format_str, 
                       const  month_short_names, 
                       const  month_long_names, 
                       const  weekday_short_names, 
                       const  weekday_long_names);
  2. (const  format_str, const  locale);
  3. (const format_date_parser< charT > & fdp);

format_date_parser public member functions

  1.  () ;
  2. void ( format_str);
  3. void (const  month_names);
  4. void (const  month_names);
  5. void (const  weekday_names);
  6. void (const  weekday_names);
  7.  (const  value, 
                         const  format_str, 
                         const special_values_parser< charT > & sv_parser) ;
  8.  (charT > & sitr, 
                         charT > & stream_end, 
                         const special_values_parser< charT > & sv_parser) ;
  9.  (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.

  10.  (charT > & sitr, 
                           charT > & stream_end, 
                            format_str) ;
    Throws bad_month if unable to parse.
  11.  (charT > & sitr, 
                           charT > & stream_end, 
                            format_str,  mr) ;
    Throws bad_month if unable to parse.
  12.  (charT > & sitr, 
                                    charT > & stream_end) ;
    Expects 1 or 2 digits 1-31. Throws bad_day_of_month if unable to parse.
  13.  (charT > & sitr, 
                                charT > & stream_end) ;
    Expects 2 digits 01-31. Throws bad_day_of_month if unable to parse.
  14.  
    (charT > & sitr, 
                  charT > & stream_end, 
                   format_str) ;
  15.  
    (charT > & sitr, 
                  charT > & stream_end, 
                   format_str,  mr) ;
  16.  (charT > & sitr, 
                         charT > & stream_end, 
                          format_str) ;
    throws bad_year if unable to parse
  17.  (charT > & sitr, 
                         charT > & stream_end, 
                          format_str,  mr) ;
    throws bad_year if unable to parse

PrevUpHomeNext