Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template date_generator_formatter

boost::date_time::date_generator_formatter — Formats date_generators for output.

Synopsis

// In header: <boost/date_time/date_generator_formatter.hpp>

template<typename date_type, typename CharT, 
         typename OutItrT> 
class date_generator_formatter {
public:
  // types
  typedef partial_date<         ;
  typedef nth_kday_of_month<    ;    
  typedef first_kday_of_month<  ;  
  typedef last_kday_of_month<   ;   
  typedef first_kday_after<     ;  
  typedef first_kday_before<    ; 
  typedef                             ;        
  typedef    ;      
  typedef        ;  

  enum phrase_elements { first = =0, second, third, fourth, fifth, last, 
                         before, after, of, number_of_phrase_elements };

  // construct/copy/destruct
  ();
  (, , 
                           , , 
                           , , 
                           , , 
                           );

  // public member functions
   (,  = );
  template<typename facet_type> 
     (, , , 
                             partial_date_type &, ) ;
  template<typename facet_type> 
     (, , , 
                         nth_kday_type &, ) ;
  template<typename facet_type> 
     (, , , 
                           first_kday_type &, ) ;
  template<typename facet_type> 
     (, , , 
                          last_kday_type &, ) ;
  template<typename facet_type> 
     (, , , 
                            kday_before_type &, ) ;
  template<typename facet_type> 
     (, , , 
                           kday_after_type &, ) ;

  // private member functions
   (, ) ;

  // public data members
  static  first_string;
  static  second_string;
  static  third_string;
  static  fourth_string;
  static  fifth_string;
  static  last_string;
  static  before_string;
  static  after_string;
  static  of_string;
};

Description

Formatting of date_generators follows specific orders for the various types of date_generators.

  • partial_date => "dd Month"

  • nth_day_of_the_week_in_month => "nth weekday of month"

  • first_day_of_the_week_in_month => "first weekday of month"

  • last_day_of_the_week_in_month => "last weekday of month"

  • first_day_of_the_week_after => "weekday after"

  • first_day_of_the_week_before => "weekday before" While the order of the elements in these phrases cannot be changed, the elements themselves can be. Weekday and Month get their formats and names from the date_facet. The remaining elements are stored in the date_generator_formatter and can be customized upon construction or via a member function. The default elements are those shown in the examples above.

date_generator_formatter public construct/copy/destruct

  1. ();
    Default format elements used.
  2. ( first_str, 
                              second_str, 
                              third_str, 
                              fourth_str, 
                              fifth_str, 
                              last_str, 
                              before_str, 
                              after_str, 
                              of_str);
    Constructor that allows for a custom set of phrase elements.

date_generator_formatter public member functions

  1.  ( new_strings,  beg_pos = );
    Replace the set of phrase elements with those contained in new_strings.

    The order of the strings in the given collection is important. They must follow:

    • first, second, third, fourth, fifth, last, before, after, of.

    It is not necessary to send in a complete set if only a few elements are to be replaced as long as the correct beg_pos is used.

    Ex: To keep the default first through fifth elements, but replace the rest with a collection of:

    • "final", "prior", "following", "in". The beg_pos of date_generator_formatter::last would be used.

  2. template<typename facet_type> 
       ( next,  a_ios,  a_fill, 
                               partial_date_type & pd, 
                                facet) ;
    Put a partial_date => "dd Month".
  3. template<typename facet_type> 
       ( next,  a_ios,  a_fill, 
                           nth_kday_type & nkd,  facet) ;
    Put an nth_day_of_the_week_in_month => "nth weekday of month".
  4. template<typename facet_type> 
       ( next,  a_ios,  a_fill, 
                             first_kday_type & fkd, 
                              facet) ;
    Put a first_day_of_the_week_in_month => "first weekday of month".
  5. template<typename facet_type> 
       ( next,  a_ios,  a_fill, 
                            last_kday_type & lkd,  facet) ;
    Put a last_day_of_the_week_in_month => "last weekday of month".
  6. template<typename facet_type> 
       ( next,  a_ios,  a_fill, 
                              kday_before_type & fkb, 
                               facet) ;
    Put a first_day_of_the_week_before => "weekday before".
  7. template<typename facet_type> 
       ( next,  a_ios,  a_fill, 
                             kday_after_type & fka, 
                              facet) ;
    Put a first_day_of_the_week_after => "weekday after".

date_generator_formatter private member functions

  1.  ( next,  str) ;
    helper function to put the various member string into stream

PrevUpHomeNext