diff --git a/tz.html b/tz.html index 733d279..c7d254e 100644 --- a/tz.html +++ b/tz.html @@ -26,7 +26,7 @@

Howard E. Hinnant
-2017-02-26
+2017-03-02

Time Zone Database Parser

@@ -59,6 +59,7 @@
  • make_zoned
  • to_stream
  • format
  • +
  • from_stream
  • parse
  • utc_clock
  • tai_clock
  • @@ -2172,74 +2173,62 @@ For the overloads taking a zoned_time it is the value returned by -

    parse

    +

    from_stream

    -

    -One can parse in a year_month_day, sys_time<Duration>, -local_time<Duration>, utc_time<Duration>, -tai_time<Duration>, gps_time<Duration>, -or a duration<Rep, Period>. -Optionally, one can also pass in a reference -to a std::string in order to capture the time zone abbreviation, or one -can pass in a reference to a std::chrono::minutes to capture a time zone -UTC offset (formatted as +0000), or one can pass in both in either order. -

    - -

    -Each of the functions below return a parse_manip manipulator which is -specialized on the type to be parsed, and which can be used to extract the desired -information from a stream. -

    -template <class Parsable, class CharT, class Traits = std::char_traits<CharT>>
    -struct parse_manip;
    +template <class CharT, class Traits>
    +void
    +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
    +            year_month_day& ymd, std::basic_string<CharT, Traits>* abbrev = nullptr,
    +            std::chrono::minutes* offset = nullptr);
     
    -template <class Parsable, class CharT, class Traits>
    -typename parse_manip<Parsable, CharT, Traits>::type
    -parse(const std::basic_string<CharT, Traits>& format, Parsable& tp);
    +template <class Duration, class CharT, class Traits>
    +void
    +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
    +            sys_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
    +            std::chrono::minutes* offset = nullptr);
     
    -template <class Parsable, class CharT, class Traits>
    -typename parse_manip<Parsable, CharT, Traits>::type
    -parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
    -      std::basic_string<CharT, Traits>& abbrev);
    +template <class Duration, class CharT, class Traits>
    +void
    +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
    +            local_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
    +            std::chrono::minutes* offset = nullptr);
     
    -template <class Parsable, class CharT, class Traits>
    -typename parse_manip<Parsable, CharT, Traits>::type
    -parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
    -      std::chrono::minutes& offset);
    +template <class Rep, class Period, class CharT, class Traits>
    +void
    +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
    +            std::chrono::duration<Rep, Period>& d,
    +            std::basic_string<CharT, Traits>* abbrev = nullptr,
    +            std::chrono::minutes* offset = nullptr);
     
    -template <class Parsable, class CharT, class Traits>
    -typename parse_manip<Parsable, CharT, Traits>::type
    -parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
    -      std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset);
    +template <class Duration, class CharT, class Traits>
    +void
    +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
    +            utc_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
    +            std::chrono::minutes* offset = nullptr);
     
    -// const CharT* formats
    +template <class Duration, class CharT, class Traits>
    +void
    +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
    +            tai_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
    +            std::chrono::minutes* offset = nullptr);
     
    -template <class Parsable, class CharT>
    -typename parse_manip<Parsable, CharT>::type
    -parse(const CharT* format, Parsable& tp);
    -
    -template <class Parsable, class CharT, class Traits>
    -typename parse_manip<Parsable, CharT>::type
    -parse(const CharT* format, Parsable& tp, std::basic_string<CharT, Traits>& abbrev);
    -
    -template <class Parsable, class CharT>
    -typename parse_manip<Parsable, CharT>::type
    -parse(const CharT* format, Parsable& tp, std::chrono::minutes& offset);
    -
    -template <class Parsable, class CharT, class Traits>
    -typename parse_manip<Parsable, CharT>::type
    -parse(const CharT* format, Parsable& tp,
    -      std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset);
    +template <class Duration, class CharT, class Traits>
    +void
    +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
    +            gps_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
    +            std::chrono::minutes* offset = nullptr);
     
    +

    Effects: These functions attempt to parse an object out of -is according to format. If the parse is unsuccessful, +is according to fmt. If the parse is unsuccessful, calls is.setstate(std::ios::failbit) which may throw an exception. -tp, abbrev, and offset are altered only in -the event of a successful parse. +tp, *abbrev, and *offset are altered only in +the event of a successful parse, for the latter two, only if they are not equal to +nullptr.

    @@ -2253,23 +2242,24 @@ If %F appears in the format string it is interpreted a

  • -If %S or %T appears in the format string -and the argument tp has precision finer than seconds, then the -seconds are parsed as a double, and if that parse is successful +If %S or %T appears in the format string and the +argument tp has precision that is not implicitly convertible to seconds, then +the seconds are parsed as a double, and if that parse is successful contributes to the time stamp as if -round<Duration>(duration<double>{s}) where -s is a local variable holding the parsed double. +round<Duration>(duration<double>{s}) where s is a +local variable holding the parsed double.

  • If %z appears in the format string and an offset is -successfully parsed, the overloads taking sys_time interprets the +successfully parsed, the overloads taking sys_time, utc_time, +tai_time and gps_time interpret the parsed time as a local time and subtracts the offset prior to assigning the value to tp, resulting in a value of tp representing a -UTC timestamp. The overloads taking local_time require a valid -parse of the offset, but then ignore the offset in assigning a value to the -local_time<Duration>& tp. If offset is -passed in, on successful parse it will hold the value represented by +UTC timestamp. The remaining overloads require a valid +parse of the offset, but then ignore the offset in assigning a value to +tp. If offset is not equal to nullptr, +on successful parse *offset will hold the value represented by %z if present, or will be assigned 0min if %z is not present.

    @@ -2285,11 +2275,13 @@ hours digit is optional:
  • If %Z appears in the format string then an abbreviation is required in that position for a successful parse. The -abbreviation will be parsed as a std::string (delimited by white +abbreviation will be parsed as a std::basic_string<CharT, Traits> +(delimited by white space). The parsed abbreviation does not have to be a valid time zone -abbreviation, and has no impact on the value parsed into tp. Using -the overloads that take a std::string& one can discover what -that parsed abbreviation is. On successful parse, abbrev will be +abbreviation, and has no impact on the value parsed into tp. If + abbrev is not equal to nullptr one can discover what +that parsed abbreviation is. On successful parse, and if abbrev != nullptr, +*abbrev will be assigned the value represented by %Z if present, or assigned the empty string if %Z is not present.

  • @@ -2304,6 +2296,56 @@ Given a UTC offset, one might even narrow that list down further.
    +

    parse

    +
    +

    +Each of the functions below return a manipulator which can be used to extract the +desired information from a stream. These functions do not participate in overload +resolution unless Parsable has a corresponding from_stream +overload. +

    + +
    +template <class Parsable, class CharT, class Traits>
    +unspecified
    +parse(const std::basic_string<CharT, Traits>& format, Parsable& tp);
    +
    +template <class Parsable, class CharT, class Traits>
    +unspecified
    +parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
    +      std::basic_string<CharT, Traits>& abbrev);
    +
    +template <class Parsable, class CharT, class Traits>
    +unspecified
    +parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
    +      std::chrono::minutes& offset);
    +
    +template <class Parsable, class CharT, class Traits>
    +unspecified
    +parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
    +      std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset);
    +
    +// const CharT* formats
    +
    +template <class Parsable, class CharT>
    +unspecified
    +parse(const CharT* format, Parsable& tp);
    +
    +template <class Parsable, class CharT, class Traits>
    +unspecified
    +parse(const CharT* format, Parsable& tp, std::basic_string<CharT, Traits>& abbrev);
    +
    +template <class Parsable, class CharT>
    +unspecified
    +parse(const CharT* format, Parsable& tp, std::chrono::minutes& offset);
    +
    +template <class Parsable, class CharT, class Traits>
    +unspecified
    +parse(const CharT* format, Parsable& tp,
    +      std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset);
    +
    +
    +

    utc_clock