Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template period_formatter

boost::date_time::period_formatter — Not a facet, but a class used to specify and control period formats.

Synopsis

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

template<typename CharT, 
         typename OutItrT> 
class period_formatter {
public:
  // types
  typedef                      ;    
  typedef                                           ;      
  typedef  ; 
  typedef       ;

  enum range_display_options { AS_OPEN_RANGE, AS_CLOSED_RANGE };

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

  // public member functions
   () ;
   () ;
   () ;
   () ;
   () ;
   (, , 
                         , );
  template<typename period_type, typename facet_type> 
     (, , , 
                       , ) ;

  // public data members
  static  default_period_separator;
  static  default_period_start_delimeter;
  static  default_period_open_range_end_delimeter;
  static  default_period_closed_range_end_delimeter;
};

Description

Provides settings for the following:

  • period_separator – default '/'

  • period_open_start_delimeter – default '['

  • period_open_range_end_delimeter – default ')'

  • period_closed_range_end_delimeter – default ']'

  • display_as_open_range, display_as_closed_range – default closed_range

Thus the default formatting for a period is as follows:

[

So for a typical date_period this would be

[

where the date formatting is controlled by the date facet

period_formatter public construct/copy/destruct

  1. ( range_option_in = , 
                      period_separator = , 
                      period_start_delimeter = , 
                      period_open_range_end_delimeter = , 
                      period_closed_range_end_delimeter = );
    Constructor that sets up period formatter options – default should suffice most cases.

period_formatter public member functions

  1.  ( oitr) ;
    Puts the characters between period elements into stream – default is /.
  2.  ( oitr) ;
    Puts the period start characters into stream – default is [.
  3.  ( oitr) ;
    Puts the period end characters into stream as controled by open/closed range setting.
  4.  () ;
  5.  ( option) ;
    Reset the range_option control.
  6.  ( separator, 
                            start_delim, 
                            open_end_delim, 
                            closed_end_delim);
    Change the delimiter strings.
  7. template<typename period_type, typename facet_type> 
       ( next,  a_ios,  a_fill, 
                          p,  facet) ;
    Generic code to output a period – no matter the period type.

    This generic code will output any period using a facet to to output the 'elements'. For example, in the case of a date_period the elements will be instances of a date which will be formatted according the to setup in the passed facet parameter.

    The steps for formatting a period are always the same:

    • put the start delimiter

    • put start element

    • put the separator

    • put either last or end element depending on range settings

    • put end delimeter depending on range settings

    Thus for a typical date period the result might look like this:

    [


PrevUpHomeNext