# Time Input Facet

Introduction - Construction - Accessors

Introduction

The `boost::date_time::time_input_facet` is an extension of the `date_input_facet`. It is typedef'ed in the `boost::posix_time` namespace as `time_input_facet` and `wtime_input_facet`. It is typedef'ed in the `boost::local_time` namespace as `local_time_input_facet` and `wlocal_time_input_facet`.

Construction

Syntax | Description
--- | ---

    time_input_facet()

Default constructor

    time_input_facet(string_type)

Format given will be used for date/time input. All other formats will use their defaults.

    time_input_facet(...)
      Parameters:
        string_type format
        format_date_parser_type
        special_values_parser_type
        period_parser_type
        date_gen_parser_type

Format given will be used for date/time input. The remaining parameters are parser objects. Further details on these objects can be found here.

Accessors

The time_input_facet inherits all the public date_input_facet methods. Therefore, the date_input_facet methods are not listed here. Instead, they can be found by following this link.

Syntax | Description
--- | ---
Example

    void set_iso_format()

Sets the time format to ISO

    f->set_iso_format();
    // "%Y%m%dT%H%M%S%F%q"
    "20051225T132536.789-0700"

    void set_iso_extended_format()

Sets the date format to ISO Extended

    f->set_iso_extended_format();
    // "%Y-%m-%d %H:%M:%S%F %Q"
    "2005-12-25 13:25:36.789 -07:00"

    void time_duration_format(...)
      Parameter:
        char_type*

Sets the time_duration format.

    f->time_duration_format("%H:%M");
    // hours and minutes only

    InItrT get(...)
      Common parameters for all
      'get' functions:
        InItrT from
        InItrT to
        ios_base
      Unique parameter for 'get' funcs:
        gregorian object

There are 3 get functions in the time_input_facet. The common parameters are: an iterator pointing to the begining of the stream, an iterator pointing to the end of the stream, and an ios_base object. Each unique gregorian object has it's own get function. Each unique get function is described below.

    InItrT get(..., ptime)

Gets a ptime object from the stream using the format set by `format(...)` or the default.

    ss.str("2005-Jan-01 13:12:01");
    ss >> pt; // default format

    InItrT get(..., time_duration)

Gets a time_duration object from the stream using the format set by `time_duration_format(...)` or the default.

    ss.str("01:25:15.000123000");
    ss >> td; // default format

    InItrT get(..., time_period)

Gets a time_period from the stream. The format of the dates/times will use the format set by `format(..)` or the default date and time format. The type of period (open or closed range) and the delimiters used are those used by the period_parser.

see the tutorial for a complete example.