Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template date_facet

boost::date_time::date_facet

Synopsis

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

template<typename date_type, typename CharT, 
         typename OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > > 
class date_facet {
public:
  // types
  typedef date_type::duration_type                             duration_type;                
  typedef date_type::day_of_week_type                          day_of_week_type;             
  typedef date_type::day_type                                  day_type;                     
  typedef date_type::month_type                                month_type;                   
  typedef boost::date_time::period< date_type, duration_type > period_type;                  
  typedef std::basic_string< CharT >                           string_type;                  
  typedef CharT                                                char_type;                    
  typedef boost::date_time::period_formatter< CharT >          period_formatter_type;        
  typedef boost::date_time::special_values_formatter< CharT >  special_values_formatter_type;
  typedef std::vector< std::basic_string< CharT > >            input_collection_type;        
  typedef date_generator_formatter< date_type, CharT >         date_gen_formatter_type;      
  typedef partial_date< date_type >                            partial_date_type;            
  typedef nth_kday_of_month< date_type >                       nth_kday_type;                
  typedef first_kday_of_month< date_type >                     first_kday_type;              
  typedef last_kday_of_month< date_type >                      last_kday_type;               
  typedef first_kday_after< date_type >                        kday_after_type;              
  typedef first_kday_before< date_type >                       kday_before_type;             

  // construct/copy/destruct
  date_facet(::size_t = 0);
  date_facet(const char_type *, const input_collection_type &, ::size_t = 0);
  date_facet(const char_type *, 
             period_formatter_type = period_formatter_type(), 
             special_values_formatter_type = special_values_formatter_type(), 
             date_gen_formatter_type = date_gen_formatter_type(), 
             ::size_t = 0);

  // public member functions
  std::locale::id & __get_id(void) const;
  void format(const char_type *const );
  void set_iso_format();
  void set_iso_extended_format();
  void month_format(const char_type *const );
  void weekday_format(const char_type *const );
  void period_formatter(period_formatter_type);
  void special_values_formatter(const special_values_formatter_type &);
  void short_weekday_names(const input_collection_type &);
  void long_weekday_names(const input_collection_type &);
  void short_month_names(const input_collection_type &);
  void long_month_names(const input_collection_type &);
  void date_gen_phrase_strings(const input_collection_type &, 
                               typename date_gen_formatter_type::phrase_elements = date_gen_formatter_type::first);
  OutItrT put(OutItrT, std::ios_base &, char_type, const date_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const duration_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const month_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const day_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const day_of_week_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const period_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const partial_date_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const nth_kday_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const first_kday_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const last_kday_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const kday_before_type &) const;
  OutItrT put(OutItrT, std::ios_base &, char_type, const kday_after_type &) const;

  // protected member functions
  OutItrT do_put_special(OutItrT, std::ios_base &, char_type, 
                         const boost::date_time::special_values) const;
  OutItrT do_put_tm(OutItrT, std::ios_base &, char_type, const tm &, 
                    string_type) const;
  static const char_type long_weekday_format;
  static const char_type short_weekday_format;
  static const char_type long_month_format;
  static const char_type short_month_format;
  static const char_type default_period_separator;
  static const char_type standard_format_specifier;
  static const char_type iso_format_specifier;
  static const char_type iso_format_extended_specifier;
  static const char_type default_date_format;
  static std::locale::id id;
};

Description

Class that provides format based I/O facet for date types.

This class allows the formatting of dates by using format string. Format strings are:

  • A => long_weekday_format - Full name Ex: Tuesday

  • a => short_weekday_format - Three letter abbreviation Ex: Tue

  • B => long_month_format - Full name Ex: October

  • b => short_month_format - Three letter abbreviation Ex: Oct

  • x => standard_format_specifier - defined by the locale

  • Y-b-d => default_date_format - YYYY-Mon-dd

Default month format == b Default weekday format == a

date_facet public construct/copy/destruct

  1. date_facet(::size_t a_ref = 0);
  2. date_facet(const char_type * format_str, 
               const input_collection_type & short_names, ::size_t ref_count = 0);
  3. date_facet(const char_type * format_str, 
               period_formatter_type per_formatter = period_formatter_type(), 
               special_values_formatter_type sv_formatter = special_values_formatter_type(), 
               date_gen_formatter_type dg_formatter = date_gen_formatter_type(), 
               ::size_t ref_count = 0);

date_facet public member functions

  1. std::locale::id & __get_id(void) const;
  2. void format(const char_type *const  format_str);
  3. void set_iso_format();
  4. void set_iso_extended_format();
  5. void month_format(const char_type *const  format_str);
  6. void weekday_format(const char_type *const  format_str);
  7. void period_formatter(period_formatter_type per_formatter);
  8. void special_values_formatter(const special_values_formatter_type & svf);
  9. void short_weekday_names(const input_collection_type & short_names);
  10. void long_weekday_names(const input_collection_type & long_names);
  11. void short_month_names(const input_collection_type & short_names);
  12. void long_month_names(const input_collection_type & long_names);
  13. void date_gen_phrase_strings(const input_collection_type & new_strings, 
                                 typename date_gen_formatter_type::phrase_elements beg_pos = date_gen_formatter_type::first);
  14. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const date_type & d) const;
  15. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const duration_type & dd) const;
  16. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const month_type & m) const;
  17. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const day_type & day) const;
    puts the day of month
  18. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const day_of_week_type & dow) const;
  19. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const period_type & p) const;
  20. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const partial_date_type & pd) const;
  21. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const nth_kday_type & nkd) const;
  22. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const first_kday_type & fkd) const;
  23. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const last_kday_type & lkd) const;
  24. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const kday_before_type & fkb) const;
  25. OutItrT put(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                const kday_after_type & fka) const;

date_facet protected member functions

  1. OutItrT do_put_special(OutItrT next, std::ios_base &, char_type, 
                           const boost::date_time::special_values sv) const;
  2. OutItrT do_put_tm(OutItrT next, std::ios_base & a_ios, char_type fill_char, 
                      const tm & tm_value, string_type a_format) const;

PrevUpHomeNext