| Home | Libraries | People | FAQ | More

## Class template time_input_facet

boost::date_time::time_input_facet — Facet for format-based input.

## Synopsis

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

    template<typename time_type, typename CharT,
             typename InItrT = std::istreambuf_iterator<CharT, std::char_traits<CharT> > >
    class time_input_facet : public boost::date_time::date_input_facet< time_type::date_type, CharT, InItrT >
    {
    public:
      // types
      typedef time_type::date_type                                                               date_type;
      typedef time_type::time_duration_type                                                      time_duration_type;
      typedef time_duration_type::fractional_seconds_type                                        fracional_seconds_type;
      typedef boost::date_time::period< time_type, time_duration_type >                          period_type;
      typedef boost::date_time::date_input_facet< typename time_type::date_type, CharT, InItrT > base_type;
      typedef base_type::duration_type                                                           date_duration_type;
      typedef base_type::year_type                                                               year_type;
      typedef base_type::month_type                                                              month_type;
      typedef base_type::day_type                                                                day_type;
      typedef base_type::string_type                                                             string_type;
      typedef string_type::const_iterator                                                        const_itr;
      typedef base_type::char_type                                                               char_type;
      typedef base_type::format_date_parser_type                                                 format_date_parser_type;
      typedef base_type::period_parser_type                                                      period_parser_type;
      typedef base_type::special_values_parser_type                                              special_values_parser_type;
      typedef base_type::date_gen_parser_type                                                    date_gen_parser_type;
      typedef base_type::special_values_parser_type::match_results                               match_results;

      // construct/copy/destruct
      time_input_facet(const string_type &, ::size_t = 0);
      time_input_facet(const string_type &, const format_date_parser_type &,
                       const special_values_parser_type &,
                       const period_parser_type &, const date_gen_parser_type &,
                       ::size_t = 0);
      time_input_facet(::size_t = 0);

      // public member functions
      void time_duration_format(const char_type *const );
      void set_iso_format();
      void set_iso_extended_format();
      InItrT get(InItrT &, InItrT &, std::ios_base &, period_type &) const;
      InItrT get(InItrT &, InItrT &, std::ios_base &, time_duration_type &) const;
      InItrT get(InItrT &, InItrT &, std::ios_base &, time_type &) const;
      InItrT get_local_time(InItrT &, InItrT &, std::ios_base &, time_type &,
                            string_type &) const;

      // protected member functions
      InItrT get(InItrT &, InItrT &, std::ios_base &, time_type &, string_type &,
                 bool) const;
      template<typename temporal_type>
        InItrT check_special_value(InItrT &, InItrT &, temporal_type &,
                                   char_type = '\0') const;
      void parse_frac_type(InItrT &, InItrT &, fracional_seconds_type &) const;

      // private member functions
      template<typename int_type>
        int_type decimal_adjust(int_type, const unsigned short) const;
      static const char_type * fractional_seconds_format;
      static const char_type * fractional_seconds_or_none_format;
      static const char_type * seconds_with_fractional_seconds_format;
      static const char_type * seconds_format;
      static const char_type * standard_format;
      static const char_type * zone_abbrev_format;
      static const char_type * zone_name_format;
      static const char_type * zone_iso_format;
      static const char_type * zone_iso_extended_format;
      static const char_type * duration_seperator;
      static const char_type * iso_time_format_specifier;
      static const char_type * iso_time_format_extended_specifier;
      static const char_type * default_time_input_format;
      static const char_type * default_time_duration_format;
      static std::locale::id id;
    };

## Description

### `time_input_facet` public construct/copy/destruct

1.     time_input_facet(const string_type & format, ::size_t a_ref = 0);

   Constructor that takes a format string for a ptime.

2.     time_input_facet(const string_type & format,
                        const format_date_parser_type & date_parser,
                        const special_values_parser_type & sv_parser,
                        const period_parser_type & per_parser,
                        const date_gen_parser_type & date_gen_parser,
                        ::size_t a_ref = 0);

3.     time_input_facet(::size_t a_ref = 0);

   sets default formats for ptime, local_date_time, and time_duration

### `time_input_facet` public member functions

1.     void time_duration_format(const char_type *const  format);

   Set the format for time_duration.

2.     void set_iso_format();

3.     void set_iso_extended_format();

4.     InItrT get(InItrT & sitr, InItrT & stream_end, std::ios_base & a_ios,
                  period_type & p) const;

5.     InItrT get(InItrT & sitr, InItrT & stream_end, std::ios_base & a_ios,
                  time_duration_type & td) const;

6.     InItrT get(InItrT & sitr, InItrT & stream_end, std::ios_base & a_ios,
                  time_type & t) const;

   Parses a time object from the input stream.

7.     InItrT get_local_time(InItrT & sitr, InItrT & stream_end,
                             std::ios_base & a_ios, time_type & t,
                             string_type & tz_str) const;

   Expects a time_zone in the input stream.

### `time_input_facet` protected member functions

1.     InItrT get(InItrT & sitr, InItrT & stream_end, std::ios_base & a_ios,
                  time_type & t, string_type & tz_str, bool time_is_local) const;

2.     template<typename temporal_type>
         InItrT check_special_value(InItrT & sitr, InItrT & stream_end,
                                    temporal_type & tt, char_type c = '\0') const;

   Helper function to check for special_value.

   First character may have been consumed during original parse attempt. Parameter 'c' should be a copy of that character. Throws ios_base::failure if parse fails.

3.     void parse_frac_type(InItrT & sitr, InItrT & stream_end,
                            fracional_seconds_type & frac) const;

   Helper function for parsing a fractional second type from the stream.

### `time_input_facet` private member functions

1.     template<typename int_type>
         int_type decimal_adjust(int_type val, const unsigned short places) const;

   Helper function to adjust trailing zeros when parsing fractional digits.